简体   繁体   English

嵌套部分嵌套

[英]Nested Partials in Assemble

Revisiting Assemble after a few months away from it. 几个月后重新组装。 I'm building out my Gruntfile.js with the Assemble options. 我正在使用Assemble选项构建我的Gruntfile.js。

Setup 设定

Gruntfile.js

assemble: {
  options: {
    flatten: true,
    production: false, // set to true before delivery
    assets: 'assets',
    postprocess: require('pretty'),

    // Metadata
    pkg: '<%= pkg %>',
    site: '<%= site %>',

    // Templates
    partials: '<%= site.includes %>',
    layoutdir: '<%= site.layouts %>',
    layout: '<%= site.layout %>',
  },
  site: {
    files: {'<%= site.dest %>/': ['<%= site.templates %>/pages/*.hbs']}
  }
}

_config.yml

# Assemble Templates
templates:        <%= site.src %>/templates
includes:         <%= site.src %>/templates/includes/**/*.hbs  
layouts:          <%= site.src %>/templates/layouts
layout:           default.hbs

Question(s) 问题(S)

Within my .hbs files for the layouts, how would I go about referencing nested partials, ie temples/includes/ global /head.hbs 在用于布局的.hbs文件中,我将如何引用嵌套的部分,即Temples / includes / global /head.hbs

This is how you'd call it if was at the root level: 如果是在根级别,这就是您的称呼方式:

<head>
  {{> head }}
</head>

What's the markup for a nested partial? 嵌套部分的标记是什么? Check the docs and it didnt come to me as an answer there; 检查文档,那里没有答案。 sorry. 抱歉。

You access the partial the same way {{> head }} . 您可以通过{{> head }}相同的方式访问部分。 We're only using the basename of the file to name the partial. 我们仅使用文件的basename来命名部分文件。 There's no built in way to modify that in assemble 0.4.x. 在汇编0.4.x中没有内置的方法可以对其进行修改。

If you have different partials with the same filename in different folders, then the last one wins. 如果您在不同的文件夹中具有相同文件名的不同部分,则最后一个将获胜。

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

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