Cyr*_*hil 1 html ruby erb partials middleman
如何通过标记调用将自定义变量发送到部分变量.
<%= partial (:contentHeader, :title=>"Title Goes here") %>
/*trying to send a variable named title with "Title Goes Here" to the partial*/
Run Code Online (Sandbox Code Playgroud)
部分是这样的:
<div class = "contentHeader">
<h2><%=title%></h2>
</div>
Run Code Online (Sandbox Code Playgroud)
所以输出结果应该是
<div class = "contentHeader">
<h2>Title Goes Here</h2>
</div>
Run Code Online (Sandbox Code Playgroud)
使用:locals将变量发送到局部,
<%= partial(:contentHeader, :locals => { :title => "Title Goes here" }) %>
Run Code Online (Sandbox Code Playgroud)