Skip to content

Instantly share code, notes, and snippets.

@dahlia
Created December 29, 2012 14:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dahlia/4407166 to your computer and use it in GitHub Desktop.
Save dahlia/4407166 to your computer and use it in GitHub Desktop.
Jinja2 htmlfill ext
# htmlfill
with app.test_request_context('/'):
html = render_template_string('''
{%- autoescape true -%}
{%- form 'user.signup' with {'a': 123, 'b': 456} -%}
<input type="number" name="a"> {{- '' -}}
<input type="number" name="b" value="2"> {{- '' -}}
<input type="number" name="c" value="3">
{%- endform -%}
{%- endautoescape -%}
''')
expected = ('<form action="/users/" method="POST">'
'<input type="number" name="a" value="123">'
'<input type="number" name="b" value="456">'
'<input type="number" name="c" value=""></form>')
assert html == expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment