This is intentional. When rendering a partial in Haml, just as in ERB, 
the partial is entirely rendered and then inserted into the page. The 
Haml code doesn't get substituted into the template; rather, the result 
of compiling that code is inserted into the result.

The "unexpected kEND" error you're getting comes from you indenting 
stuff where you shouldn't be. When you nest tags within a Ruby command, 
like "-" or "=", Haml thinks you want a Ruby block, like an if statement 
or an iterator. Thus, it puts an implicit "end" at the end of the block. 
However, render doesn't take a block (nor did you use "do" to give it a 
block even if it did), so the Ruby compiled complained about the "do".

Make sense?

- Nathan

Jeff wrote:
> Hi Nathan,
>
> I'm having a problem with a nested controller.  Have I found a bug or
> am I doing something wrong?
>
> Thanks,
> Jeff
>
> In scenario 1, I have this partial, _post.haml:
> %div.post[post]
>   %h3.title= h post.title
>   .publish-on= h post.publish_at.to_s(:published)
>   = textize(h post.content)
>
>
> I want to place the first line into another partial, shared/
> _post_start.haml:
> %div.post[post]
>
> And then change the first line of the original partial, post.haml,
> creating Scenario 2:
> = render :partial => 'shared/post_start.haml'
>   %h3.title= h post.title
>   .publish-on= h post.publish_at.to_s(:published)
>   = textize(h post.content)
>
> Scenario 1 renders properly, but Scenario 2 results in the error
> below.
>
> Showing app/views/articles/_post.haml where line #6 raised:
>
> (eval):27:in `compile': compile error
> (eval):27: parse error, unexpected kEND, expecting $
>
> Extracted source (around line #6):
>
> 3: = render :partial => 'shared/post_start'
> 4:   %h3.title= h post.title
> 5:   .publish-on= h post.publish_at.to_s(:published)
> 6:   = textize(h post.content)
>
> Trace of template inclusion: /app/views/posts/show.haml
>
> RAILS_ROOT: /Library/WebServer/Rails/acklife/public/../config/..
> Application Trace | Framework Trace | Full Trace
>
> #{RAILS_ROOT}/app/views/articles/_post.haml:6
> (eval):99:in `_haml_render'
> #{RAILS_ROOT}/app/controllers/posts_controller.rb:33:in `show'
> #{RAILS_ROOT}/app/controllers/posts_controller.rb:33:in `show'
>
>
>
> >
>
>   


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to