Unfortunately, this is a known bug that's very hard to solve. Since we
use a regular expression to parse tags, there's no way to handle
balanced characters like '{' and '}'. The only way to really solve this
would be to move to manually parsing the tag. This is something we'd be
interested in, so if you want to work up a patch for it, go for it
(check out render_tag in lib/haml/engine.rb).
- Nathan
Spongy wrote:
> I've been having some problems with one of my templates.
>
> These are the template sections and errors I've been getting (also at
> http://pastie.caboo.se/81401)
>
> ## HAML snippet
> - payment.invoices.each do |invoice|
> %tr.invoice
> %td{:colspan => "2"}= h("Invoice #{invoice.remote_number}")
> %td= number_to_currency(invoice.amount, :unit => "£")
> %td
>
> ## Error
> (eval):43:in `compile': compile error
> (eval):32: syntax error, unexpected '}', expecting ')'
> _hamlout.open_tag("td", nil, true, {}, nil, "\")", :colspan => "2"}=
> h("Invoice #{invoice.remote_number)
> ^
> (eval):32: syntax error, unexpected ')', expecting '}'
> (eval):38: syntax error, unexpected kEND, expecting '}'
> (eval):42: syntax error, unexpected kEND, expecting '}'
>
> ## Full Template
> - page_title "Your Payments"
>
> %table
> %thead
> %tr
> %th ID
> %th Invoices
> %th Amount
> %th Paid on
> %tbody
> - @payments.each do |payment|
> %tr.payment
> %td= h "Payment #{payment.id}"
> %td= h payment.invoices.count
> %td= h payment.amount
> %td= payment.paid_at ? payment.paid_at.strftime("%m/%d/%Y") :
> 'UNPAID'
> - payment.invoices.each do |invoice|
> %tr.invoice
> %td{:colspan => 2}= h("Invoice #{invoice.remote_number}")
> %td= number_to_currency(invoice.amount, :unit => "£")
> %td blank
>
> ## Attempt 2 Template
> - page_title "Your Payments"
>
> %table
> %thead
> %tr
> %th ID
> %th Invoices
> %th Amount
> %th Paid on
> %tbody
> - @payments.each do |payment|
> %tr.payment
> %td{:test => :thing}= h "Payment #{payment.id}"
> %td= h payment.invoices.count
> %td= h payment.amount
> %td= payment.paid_at ? payment.paid_at.strftime("%m/%d/%Y") :
> 'UNPAID'
> - payment.invoices.each do |invoice|
> %tr.invoice
> %td{:colspan => 2}= h("Invoice #{invoice.remote_number}")
> %td= number_to_currency(invoice.amount, :unit => "£")
> %td blank
>
> ## Attempt 2 Error
> (eval):42:in `compile': compile error
> (eval):13: syntax error, unexpected '}', expecting ')'
> _hamlout.open_tag("td", nil, true, {}, nil, "\"", :test => :thing}= h
> "Payment #{payment.id)
> ^
> (eval):13: syntax error, unexpected ')', expecting '}'
> (eval):28: syntax error, unexpected kDO_BLOCK, expecting '}'
> payment.invoices.each do |invoice|
> ^
> (eval):31: syntax error, unexpected '}', expecting ')'
> _hamlout.open_tag("td", nil, true, {}, nil, "\")", :colspan => 2}=
> h("Invoice #{invoice.remote_number)
> ^
> (eval):31: syntax error, unexpected ')', expecting '}'
> (eval):37: syntax error, unexpected kEND, expecting '}'
> (eval):41: syntax error, unexpected kEND, expecting '}'
>
> Eventually I tried changing the "Payment" and "Invoice" strings to
> ["Payment", payment.id].join(' ')
> and the errors have disappeared.
>
> I am using r570 and also had the same problem on r566
>
> Any ideas on how or what this is caused by and I can poke around in
> the engine.
>
> Cheers,
> Geoff
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---