Custom javascripts list in Handlebars needs #each – but how?

眉间皱痕 提交于 2019-12-11 18:27:36

问题


I am building a Handlebars partial template to load a list of scripts that will be concatenated by useref. I would like to customize the list on individual pages using an inline block. I can get the name of the js-output to register, and the first js-input, but the list of js-inputs only renders the first item.

I've tried various {{#each}} configurations, both in the template and within the inline script, but no success.

Here's what I have so far – it's working except for the custom list of js-inputs.

The partial template:

{{!-- includes/js02.hbs --}}
<!--build:js assets/js/{{js-output}}.js -->
<script src="assets/js/{{js-input}}.js"></script>
<!-- endbuild -->

On the Page: The inline block modifier:

 {{!-- Customize page JS before concatenation. --}}
   {{#*inline "js02-block"}}
    {{> includes/js02
      js-output="minor.min"
      js-input="c"
      js-input="a"
      js-input="b"
    }}
  {{/inline}}

The code renders like this:

<!--build:js assets/js/minor.min.js -->
<script src="assets/js/c.js"></script>
<!-- endbuild -->

I want to see:

    <!--build:js assets/js/minor.min.js -->
    <script src="assets/js/c.js"></script>
    <script src="assets/js/a.js"></script>
    <script src="assets/js/b.js"></script>
    <!-- endbuild -->

etc.

. . . and I want to customize the list on the page template.

来源:https://stackoverflow.com/questions/55804407/custom-javascripts-list-in-handlebars-needs-each-but-how

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!