Markaby/Xmlbuilder error - XmlMarkup cannot mix a text argument with a block

F

Farrel Lifson

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:html do
h1 "Header" do
p "Paragraph"
end
end
EOS
=> "html do\n h1 \"Header\" do\n p \"Paragraph\"\n end\nend\n"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
 
H

Hank Lords

I would have done like this:

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

why the lucky stiff

html do
h1 "Header" do
p "Paragraph"
end
end
EOS
=> "html do\n h1 \"Header\" do\n p \"Paragraph\"\n end\nend\n"
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

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
 
F

Farrel Lifson

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)
 
F

Farrel Lifson

The error is in the template.
h1 "Header" do; ... end

That's invalid.

Try:

html do
h1 "Header"
p "Paragraph"
end
Gah! Thanks why! I knew it was something stupid...

Farrel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top