Skip to content

Instantly share code, notes, and snippets.

@uhtred
Last active May 28, 2016 07:43
Show Gist options
  • Save uhtred/5b4893c6cb993fff8b44 to your computer and use it in GitHub Desktop.
Save uhtred/5b4893c6cb993fff8b44 to your computer and use it in GitHub Desktop.
Nunjucks Macros
{% macro input(name, value, type='text', class="") %}
<input type={{ type }} name={{ name }} value={{ value }} class="{{ class }}" />
{% endmacro %}
{% macro select(name='', id='', class='', options='', first='Selecione' ) %}
<select name="{{name}}" id="" {{ class }}>
{% if first %}
<option value="">{{first}}</option>
{% endif %}
{% for option in options %}
<option value="{{option.value}}" {{ "selected" if option.selected }}>{{option.text}}</option>
{% endfor %}
</select>
{% endmacro %}
{% macro label(text, for='', class='') %}
<label for="{{ for }}" class="{{ class }}">{{ text }}</label>
{% endmacro %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment