Created
August 5, 2022 19:38
-
-
Save dario61081/01e05ed30a78d80183b6a6a7443203f8 to your computer and use it in GitHub Desktop.
macros for jinja templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro render_field(field) %} | |
{% if field.type != 'HiddenField' %} | |
<div class="field {% if field.errors %} error {% endif %}"> | |
{{ field.label }} | |
<div class="ui input"> | |
{{ field }} | |
</div> | |
{% if field.errors %} | |
<span>{{ field.errors[0] }}</span> | |
{% endif %} | |
</div> | |
{% else %} | |
{{ field }} | |
{% endif %} | |
{% endmacro %} | |
{% macro submit(text,style='primary') %} | |
<button class="ui button {{ style }}" type="submit">{{ text }}</button> | |
{% endmacro %} | |
{% macro submit_danger(text) %} | |
<button class="ui button red" type="submit">{{ text }}</button> | |
{% endmacro %} | |
{% macro volver(url) %} | |
<a href="{{ url }}" class="ui button tertiary"> <i class="left chevron icon"></i> Volver </a> | |
{% endmacro %} | |
{% macro check_valid() %} | |
<div class="field"> | |
<label class="danger">Activar acción</label> | |
<input class="ui checkbox" type="checkbox" name="valid" id="valid" | |
onclick="$('#valid').setAttribute('disabled', $(this).target.value)"> | |
Estoy seguro de ejecutar esta acción. | |
</div> | |
{% endmacro %} | |
{% macro breadcrum(path) %} | |
<div class="ui breadcrumb"> | |
<a class="section">Home</a> | |
<div class="divider"> /</div> | |
<a class="section">Store</a> | |
<div class="divider"> /</div> | |
<div class="active section">T-Shirt</div> | |
</div> | |
{% endmacro %} | |
{% macro render_form(form) %} | |
{% for f in form %} | |
{{ render_field(f) }} | |
{% endfor %} | |
{% endmacro %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment