grunt-includes
grunt-includes copied to clipboard
Add ability to pass parameters
This is a feature request :)
I would like to do the following:
<!-- fileA.html -->
include "fileB.html?param1=value1¶m2=value2"
<!-- fileB.html -->
<div>Value of "param1" is {$param1}</div>
<div>include "another/file/{$param2}"</div>
Though maybe URL query is not the best way to pass params since it requires manual URL encoding. Maybe JSON would be better:
<!-- fileA.html -->
include "fileB.html" {"param1":"value1","param2":"value2"}
Or just a list of (JSON.stringified?) arguments like this?
<!-- fileA.html -->
include "fileB.html" "value1" "value2"
<!-- fileB.html -->
<div>Value of "param1" is {$1}</div>
<div>include "another/file/{$2}"</div>
Thanks!
Is #9 similar to what you want? If there is interest I don't have a problem implementing it.
If I understand it correctly, what your talking in #9 is providing all templates (or some group of them based on task target) with a set of global params. This is good feature too, but what I'm talking about is the ability to provide a template with specific params for each inclusion. For example:
<!-- index.html -->
<div>
include "wrapper.html" "content1"
</div>
<div>
include "wrapper.html" "content2"
</div>
<!-- wrapper.html -->
<div class="wrapper">
include "{$1}.html"
</div>
And this will include content1.html
and content2.html
.
:+1:
+1
I'd be great if it was done in a json format kinda way so you could pass arrays.
If that was possible you could do something like this:
the call:
<div>
include "your-snipper.html":{ name: "Bob", "tel": [ work: "555 732 284", home: "555 1937 736", mobile: "555 4762 1726" ] }
</div>
your-snipper.html
<div class="vcard">
<p>{{ name }}</p>
{% for number in tel %}
<p>{{ number }}</p>
{% endfor %}
</div>
But I'm just dreaming here :)
I had the same question today and just came into this page, any news on that?
+1