Forum: Ruby on Rails nested tags with contents in RXML

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eb96620826312516bb4a2d6deeee6688?d=identicon&s=25 Jean-Christophe Michel (Guest)
on 2007-04-19 12:44
(Received via mailing list)
Hi,

I'm trying to get

   <a> foo
     <b> bar </b>
   </a>

with RXML.

   xml.a('foo') {
     xml.b('bar')
   }

complains about contents and blocks not being usable together.
I think my XML is valid though. Is there a way to do this, or to trick
RXML  ?


Jean-Christophe Michel
8310c5a7c769345114597bcdef111488?d=identicon&s=25 Ben Munat (Guest)
on 2007-04-19 20:16
(Received via mailing list)
I think something like this should work:

xml.a {
  xml.text! 'foo'
  xml.b('bar')
}

The text! method sets the arg as text content of the element...

b
This topic is locked and can not be replied to.