0

在 Middleman 中,有一个称为frontmatter的功能。基本上,您可以在视图前面放置一些 YAML,然后在视图和布局中访问它,如下所示:

---
my_list:
  - one
  - two
  - three
---

<h1>List</h1>
<ol>
  <% current_page.data.my_list.each do |f| %>
  <li><%= f %></li>
  <% end %>
</ol>

帕德里诺有类似的事情吗?

4

1 回答 1

0

padrino 不提供此类功能,您通常会让这些值由您的控制器填充。

根据您的用例,您可能会使用 content_for 输出帮助程序 ( http://www.padrinorb.com/guides/application-helpers )。

如果想要在页面的“嵌套”模板中定义标题(如在 html/head/title 中)——通常由布局模板设置——这可能会有所帮助。

于 2014-09-23T07:25:01.807 回答