【问题标题】:Sending custom variables to partial - middleman将自定义变量发送到部分 - 中间人
【发布时间】:2015-09-15 23:19:55
【问题描述】:

如何通过标记调用将自定义变量发送到部分。

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

部分是这样的:

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

所以输出应该是

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

【问题讨论】:

    标签: html ruby erb partials middleman


    【解决方案1】:

    使用:locals 将变量发送到部分,

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-06
      • 1970-01-01
      • 2013-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-20
      • 1970-01-01
      相关资源
      最近更新 更多