我跳进了assemble/Grunt尝试改进我为我使用的CMS创建模板的工作流程.我想弄清楚的是:是否可以在开发时(即在"grunt watch"期间)在我的模板中使用块/部分HTML内容,但是然后用我在CMS中需要的include标记替换它最终的HTML输出(即当我做"grunt build"时).像下面这样的东西?
<div id="content">
{{! if in dev context, include this partial }}
{{#if}}
{{> body }}
{{! if in build context, include this partial }}
{{else}}
{{> body-cms-tag }}
{{/if}}
</div>
Run Code Online (Sandbox Code Playgroud)
如果在dev/watch模式下,将输出
<div id="content">
<h1>Test Headline</h1>
<p>This is just test content.</p>
</div<
Run Code Online (Sandbox Code Playgroud)
但在构建模式下,会输出
<div id="content">
<?php echo $mContext['bodyElements']; ?>
</div>
Run Code Online (Sandbox Code Playgroud)
这是可能的,使用Handlebars语法,汇编助手或Grunt任务(类似于grunt-usemin?)