XML builder templates/dashes in node names

Hi,

In an .rxml template, I need to have nodes named .
However, if I use:

xml.cross-domain-policy

I get the following error:

undefined method `domain’

It works fine if I use xml.cross_domain_policy (undercores) to generate
a tag <cross_domain_policy>. Unfortunately I need the dashes in the node
names - how is it done?

Ingo

For tags which have characters that are illegal in Ruby method names you
can use the xml.tag! method in .rxml:

xml.tag! ‘cross-domain-policy’, ‘value’

or

xml.tag! ‘cross-domain-policy’ {
xml…
}

David S.

David S. wrote:

For tags which have characters that are illegal in Ruby method names you
can use the xml.tag! method in .rxml:

xml.tag! ‘cross-domain-policy’, ‘value’

or

xml.tag! ‘cross-domain-policy’ {
xml…
}

David S.

I cannot get this to work. I get an error in my Aptana IDE.

For example if I want to take:

xml.instruct!
xml.game_logs {
  xml.game{
    xml.name(@game.name)
    xml.id({:type => :integer}, @game.id)
  }
  @game_logs.each { |game_log|
    xml.game_log{
      xml.player {
        xml.name(game_log.player.login)
        xml.score(game_log.correct_answer_count)
      }
    }
  }
}

And make game_log use dashes. What is the syntax? Thanks.

Actually I got it working in that example.

xml.game_logs {

becomes

xml.tag!('game-logs') {

but what about here:

xml.is_correct({:type => :boolean}, answer.is_correct)

this does not work:

xml.tag!('is-correct', {:type => :boolean}, answer.is_correct)

Nothing to see here - user error. That code works!

Thanks.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs