[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

Farrel Lifson

7/19/2006 7:24:00 PM

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

4 Answers

Hank Lords

7/19/2006 7:31:00 PM

0

I would have done like this:

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


2006/7/19, Farrel Lifson <farrel.lifson@gmail.com>:
> 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
>
>

why the lucky stiff

7/19/2006 7:38:00 PM

0

On Thu, Jul 20, 2006 at 04:24:07AM +0900, Farrel Lifson wrote:
> >>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

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

Farrel Lifson

7/19/2006 7:39:00 PM

0

On 19/07/06, Hank Lords <hanklords@gmail.com> 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)

Farrel Lifson

7/19/2006 7:46:00 PM

0

> 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