cds-snc / node-starter-app

Quick start application setup.... because you have to start somewhere.
MIT License
5 stars 3 forks source link

Add nunjucks spread params filter #69

Closed timarney closed 4 years ago

timarney commented 4 years ago

Added a filter to open up the possibility of using arbitrary params.

We could filter out to use only data- params for safety.

See this link for output https://cds-node-starter-pr-69.herokuapp.com/start

Will remove the sampleInput later

 {{ sampleInput({"class": "error", "data-arr1":"data-1","data-arr2":"data-2"}) }}
{% macro sampleInput(obj) %}
    <div {{""|spreadParams(obj) }}>
        your text
    </div>
{% endmacro %}

Outputs

<div class="error" data-arr1="data-1" data-arr2="data-2">
  your text
</div>