Created
January 4, 2019 23:46
-
-
Save haraonline/70f4a2c99db803f0f6fe9bf248b54b71 to your computer and use it in GitHub Desktop.
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
<!-- HTML FOR - JINJA2 FILTERS --> | |
<!-- SECTION 3: LECTURE 15 --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Data Filters</title> | |
</head> | |
<body> | |
<h2>working with jinja2 filters</h2> | |
<ul> | |
{% for movie, duration in movies|dictsort (false, 'value') %} | |
<li> {{ movie|title }} : {{ duration|round(1) }} </li> | |
{% endfor %} | |
</ul> | |
<hr> | |
<ol type="1"> | |
<li> default value : {{ name|default('value not defined', true) }}</li> <br> | |
<li> capital case : {{ film|capitalize }}</li> <br> | |
<li> length : {{ movies|length }} items in the dictionary </li> <br> | |
<li> first item : {{ movies|first }}</li> <br> | |
<li> make a list : {{ film|list }}</li> <br> | |
<li> replace data : {{ film|replace('carol', 'cookie')|upper }}</li> | |
</ol> | |
<hr> | |
{{ data }} | |
<h2>more filters</h2> | |
<p> | |
filters are like little utilities that help us modify the variables or their state. | |
for a complete list of built-in jinja2 filters, check-out the following link: | |
</p> | |
<a href="http://jinja.pocoo.org/docs/2.9/templates/#builtin-filters" target="_blank"> | |
http://jinja.pocoo.org/docs/2.9/templates/#builtin-filters | |
</a> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment