I'm using Assemble, which currently uses Handlebars 1.3. In my templates I am using the picture element with Picturefill, which uses the current spec <picture>
syntax:
<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source srcset="assets/img/responsive/example-xl.jpg" media="(min-width: 1000px)">
<source srcset="assets/img/responsive/example-l.jpg" media="(min-width: 800px)">
<source srcset="assets/img/responsive/example-m.jpg">
<!--[if IE 9]></video><![endif]-->
<img srcset="assets/img/responsive/example-m.jpg" alt="An example responsive image">
</picture>
Since parts of this will probably change (I might add media queries for example), I would like to be able to update this snippet across my entire site easily. I think a partial would be best for this. So for example, something like:
{{> picture name="example" ext=".jpg" alt="Example image" }}
with this partial
<picture>
<!--[if IE 9]><video style="display: none;"><![endif]-->
<source srcset="assets/img/responsive/{{name}}-xl{{ext}}" media="(min-width: 1000px)">
<source srcset="assets/img/responsive/{{name}}-l{{ext}}" media="(min-width: 800px)">
<source srcset="assets/img/responsive/{{name}}-m{{ext}}">
<!--[if IE 9]></video><![endif]-->
<img srcset="assets/img/responsive/{{name}}-m{{ext}}" alt="{{alt}}">
</picture>
Is there a way to do that with my version of Handlebars? I know that this is native in Handlebars 2.0, but unfortunately I'm not able to update it to that version because it's integrated in Assemble. Or is there another recommended way of doing this?
p.s.: I've read about using {{> picture this}}
here, but I'm not sure if and how that would work with multiple pictures in one page (and multiple variables in one partial). Also, I've tried using a parseJSON block helper, but that syntax is a little awkward, and a little more verbose than what I described above, so I'm wondering if there is a more efficient way to do something like this.