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

Discussion in 'Ruby' started by Farrel Lifson, Jul 19, 2006.

  1. 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
     
    Farrel Lifson, Jul 19, 2006
    #1
    1. Advertising

  2. Farrel Lifson

    Hank Lords Guest

    I would have done like this:

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


    2006/7/19, 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:
    > >> 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
    >
    >
     
    Hank Lords, Jul 19, 2006
    #2
    1. Advertising

  3. 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
     
    why the lucky stiff, Jul 19, 2006
    #3
  4. On 19/07/06, Hank Lords <> 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, Jul 19, 2006
    #4
  5. > 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
     
    Farrel Lifson, Jul 19, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. morrell
    Replies:
    1
    Views:
    966
    roy axenov
    Oct 10, 2006
  2. Andrew Cox

    Combining XmlMarkup objects?

    Andrew Cox, Jun 9, 2005, in forum: Ruby
    Replies:
    2
    Views:
    194
    Andrew Cox
    Jun 10, 2005
  3. Scott Mathieson
    Replies:
    1
    Views:
    129
    George Wang
    Sep 22, 2006
  4. bryanl
    Replies:
    0
    Views:
    86
    bryanl
    Mar 7, 2008
  5. Trans

    Markaby -> Nokogiri Issue

    Trans, Jan 12, 2009, in forum: Ruby
    Replies:
    2
    Views:
    104
    Trans
    Jan 13, 2009
Loading...

Share This Page