简体   繁体   English

合并nanoc中的项目

[英]Merge items in nanoc

I have been trying to use nanoc for generating a static website. 我一直在尝试使用nanoc来生成静态网站。 I need to organize a complex arrangement pages I want to keep my content DRY. 我需要组织一个复杂的排列页面,我希望保持我的内容干燥。

How does the concept of includes or merges work within the nanoc system? 包含或合并的概念在nanoc系统中如何工作? I have read the docs but I can't seem to find what I want. 我已经阅读了文档,但我似乎找不到我想要的东西。

For example: how can I take two partial content items and merge them together into a new content item. 例如:如何获取两个部分内容项并将它们合并为一个新的内容项。

In staticmatic you can do some like the following inside your page. staticmatic中,您可以在页面中执行以下操作。

= partial('partials/shared/navigation')

How would a similar convention work within nanoc? 类似的约定如何在nanoc中起作用?

nanoc's author here. nanoc的作者在这里。

In nanoc, partials are layouts. 在nanoc中,部分是布局。 So, you could have layouts/partials/shared/navigation.html and then render that partial like this: 所以,你可以有layouts/partials/shared/navigation.html ,然后像这样呈现那个部分:

= render '/partials/shared/navigation'

For that to work, enable the Rendering helper first, by including it somewhere in the lib/ dir (eg lib/helpers.rb ): 为了实现这一点,首先启用渲染助手,将其包含在lib/ dir中的某个位置(例如lib/helpers.rb ):

include Nanoc3::Helpers::Rendering

For more information, check out the layouts as partials section of the manual. 有关更多信息,请查看手册中的布局部分部分。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM