I have a partial that represents a header that I want to place on some of my pages. Each page, though, has a different title. I want to ‘inject’ this title into the partial.
Here’s what I’m trying to do, although it’s not working:
= render :partial => "section_head_top"
%span( id= "section_head_header") Apply
= render :partial => "section_head_divider"
Section_head_top partial code:
#section_head
#section_head_top
#section_head_content
I want the %span line to be inside of the section_head_content div. I am getting “syntax error, unexpected keyword_ensure, expecting $end” for two lines outside of my code (even when the bottom partial is removed).
How is this done?
Thank you!!
I would recommend using a local variable in your partial. For example, if your partial code looks something like this (_section_head_top.haml):
- title ||= 'Default Header' #section_head #section_head_top #section_head_content %span( id => "section_head_header")= title = render :partial => "section_head_divider"You can call this from your code:
= render :partial => "section_head_top", :locals => { :title => 'Apply' }