pyx / flask-pure

Flask-Pure - a Flask extension for Pure.css
Other
12 stars 2 forks source link

wtf implementation? #2

Open faststare opened 7 years ago

faststare commented 7 years ago

flask-bootstrap have pre-made wtf.html within the package. can I request the same with your package?

pyx commented 7 years ago

Hi, thanks for the suggestion, I did not use flask-bootstrap before, so I did not know what they do with that, I suppose it is about pre-defined macros for forms/fields rendering?

For field rendering, what I am using now is simply pass in class attributes, e.g:

{% macro render_form_field(field) %}
{% if field.type == 'BooleanField' %}
<label class="pure-checkbox">
{% for error in field.errors %}<p class="message error">{{ error }}</p>{% endfor %}
{{ field.label.text|safe }}
{{ field(**kwargs) }}
</label>
{% else %}
{% set required = kwargs.pop('required', field.flags.required) %}
{# default to 100% width #}
{% set class_ = kwargs.pop('class_', 'pure-input-1') %}
{{ field.label }}
{% for error in field.errors %}<p class="message error">{{ error }}</p>{% endfor %}
{{ field(class_=class_, required=required, **kwargs) }}
{% endif %}
{% endmacro %}

Do we need anything fancier beyond that?