-
-
Save yoloseem/4595277 to your computer and use it in GitHub Desktop.
formencode htmlfill in jinja2 template
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
# htmlfill | |
with app.test_request_context('/'): | |
html = render_template_string(''' | |
{%- autoescape true -%} | |
{%- form 'user.signin', {'method': 'POST'} | |
with {'name': 'sohee', 'pretty': 'no'}, | |
{'pretty': 'sohee is always pretty.'} -%} | |
<input type="text" name="name" /> {{- '' -}} | |
<input type="text" name="pretty" placeholder="yes" /> {{- '' -}} | |
<div id="errors"> {{- '' -}} | |
<form:error name="name"> {{- '' -}} | |
<form:error name="pretty"> {{- '' -}} | |
</div> | |
{%- endform -%} | |
{%- endautoescape -%} | |
''') | |
expected = ('<form action="/u/signin" method="POST">' | |
'<input type="text" name="name" value="sohee" />' | |
'<input type="text" name="pretty" placeholder="yes"' | |
' class="error" value="no" />' | |
'<div id="errors">' | |
'<p class="error">sohee is always pretty.</p>' | |
'</div>' | |
'</form>') | |
assert html == expected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment