Markaby/Xmlbuilder error - XmlMarkup cannot mix a text argum

Hi folks,

I’m not sure if I’m grokking how to use Markaby correctly. I’m trying
to render some external Markaby code as follows but get the
ArgumentError at the end:

require ‘markaby’
=> true

template =<<EOS
html do
h1 “Header” do
p “Paragraph”
end
end
EOS
=> “html do\n h1 “Header” do\n p “Paragraph”\n end\nend\n”

Markaby::Template.new(template).render
ArgumentError:
/usr/lib/ruby/gems/1.8/gems/builder-2.0.0/lib/builder/xmlbase.rb:53:in
`method_missing’: XmlMarkup cannot mix a text argument with a block

What would be the correct way to render the given Markaby code
fragment? The error is bubbling up from XmlBuilder

Farrel

I would have done like this:

mab = Markaby::Builder.new
mab.instance_eval template
mab.to_s

2006/7/19, Farrel L. [email protected]:

On Thu, Jul 20, 2006 at 04:24:07AM +0900, Farrel L. wrote:

/usr/lib/ruby/gems/1.8/gems/builder-2.0.0/lib/builder/xmlbase.rb:53:in
`method_missing’: XmlMarkup cannot mix a text argument with a block

What would be the correct way to render the given Markaby code
fragment? The error is bubbling up from XmlBuilder

The error is in the template.

h1 “Header” do; … end

That’s invalid.

Try:

html do
h1 “Header”
p “Paragraph”
end

Or, if the paragraph does really belong in the header:

html do
h1 { “Header” + p(“Paragraph”) }
end

The last one requires Markaby 0.4.65 or greater[1]. May good fortune
swirl
around in your Thermos forevermore.

_why

[1] gem install markaby --source code.whytheluckystiff.net

p "Paragraph"

end

Gah! Thanks why! I knew it was something stupid…

Farrel

On 19/07/06, Hank L. [email protected] wrote:

I would have done like this:

mab = Markaby::Builder.new
mab.instance_eval template
mab.to_s

That produces the same error (In digging around in the code it
Markaby::Template does that in the render method)

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