# Markaby/Xmlbuilder error - XmlMarkup cannot mix a text argum

**URL:** <https://www.ruby-forum.com/t/markaby-xmlbuilder-error-xmlmarkup-cannot-mix-a-text-argum/99024>\
**Category:** Ruby\
**Created:** [July 19, 2006, 9:25pm UTC](https://www.ruby-forum.com/t/markaby-xmlbuilder-error-xmlmarkup-cannot-mix-a-text-argum/99024 "2006-07-19T21:25:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Farrel\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9d8465/32.png) [@Farrel\_L](https://www.ruby-forum.com/u/Farrel_L)\
**Post date:** [July 19, 2006, 9:25pm UTC](https://www.ruby-forum.com/t/markaby-xmlbuilder-error-xmlmarkup-cannot-mix-a-text-argum/99024/1 "2006-07-19T21:25:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Farrel\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9d8465/32.png) [@Farrel\_L](https://www.ruby-forum.com/u/Farrel_L)\
**Post date:** [July 19, 2006, 9:32pm UTC](https://www.ruby-forum.com/t/markaby-xmlbuilder-error-xmlmarkup-cannot-mix-a-text-argum/99024/2 "2006-07-19T21:32:39Z")

</div>

I would have done like this:

mab = Markaby::Builder.new  
mab.instance\_eval template  
mab.to\_s

2006/7/19, Farrel L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![Farrel\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9d8465/32.png) [@Farrel\_L](https://www.ruby-forum.com/u/Farrel_L)\
**Post date:** [July 19, 2006, 9:39pm UTC](https://www.ruby-forum.com/t/markaby-xmlbuilder-error-xmlmarkup-cannot-mix-a-text-argum/99024/3 "2006-07-19T21:39:44Z")

</div>

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](http://code.whytheluckystiff.net)

---

<div class="post-metadata">

**Author:** ![Farrel\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9d8465/32.png) [@Farrel\_L](https://www.ruby-forum.com/u/Farrel_L)\
**Post date:** [July 19, 2006, 9:46pm UTC](https://www.ruby-forum.com/t/markaby-xmlbuilder-error-xmlmarkup-cannot-mix-a-text-argum/99024/4 "2006-07-19T21:46:26Z")

</div>

> ```
> p "Paragraph"
> 
> ```
> 
> end

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

Farrel

---

<div class="post-metadata">

**Author:** ![Farrel\_L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/9d8465/32.png) [@Farrel\_L](https://www.ruby-forum.com/u/Farrel_L)\
**Post date:** [July 19, 2006, 9:43pm UTC](https://www.ruby-forum.com/t/markaby-xmlbuilder-error-xmlmarkup-cannot-mix-a-text-argum/99024/5 "2006-07-19T21:43:16Z")

</div>

On 19/07/06, Hank L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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)
