Sending custom variables to partial - middleman

How do I send a custom variable to a partial with a call from the markup.

<%= partial (:contentHeader, :title=>"Title Goes here") %>
/*trying to send a variable named title with "Title Goes Here" to the partial*/

The partial is kind of like this:

<div class = "contentHeader">
<h2><%=title%></h2>
</div>

So the output should turn out to be

<div class = "contentHeader">
<h2>Title Goes Here</h2>
</div>

Upvotes: 1

Views: 1131

Answers (1)

jon snow
jon snow

Reputation: 3072

Use :locals to send variables to partial,

<%= partial(:contentHeader, :locals => { :title => "Title Goes here" }) %>

Upvotes: 7

Related Questions