janl / mustache.js

Minimal templating with {{mustaches}} in JavaScript
https://mustache.github.io
MIT License
16.37k stars 2.4k forks source link

Section with custom attribute #805

Open ngocducdim opened 1 year ago

ngocducdim commented 1 year ago

Hi, can we add some custom attribute like WordPress shortcode in section?, for example from this:

{
  "fontWeight": function () {
    return function (text, render) {
      return '<p style="font-weight: 400">' + render(text) + '</p>';
    }
  }
}
{{#fontWeight}}
  This text is 700
{{/fontWeight}}

to be like this:

{
  "fontWeight": function () {
    return function (text, render, props) {
      return `<p style="font-weight: ${props.size}">` + render(text) + '</p>';
    }
  }
}
{{#fontWeight[size=700]}}
  This text is 700
{{/fontWeight}}

is it possible?