jinja2

Jinja2 correctly indent included block

北城以北 提交于 2021-02-05 20:13:49
问题 I have two files: base.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>{{title}}</title> </head> <body> {% block content %} {% endblock %} </body> </html> register.html {% extends "base.html" %} {% block content %} <h1>Register</h1> <form action="" method="post" name="register"> {{ form.hidden_tag() }} {{ form.login.label }} {{ form.login(size=20) }} {{ form.password.label }} {{ form.password(size=20) }} <input type="submit" value="Register"> </form> {% endblock %} It gets

Split string into list in jinja?

情到浓时终转凉″ 提交于 2021-02-05 13:13:29
问题 I have some variables in a jinja2 template which are strings seperated by a ';'. I need to use these strings separately in the code. i.e. the variable is variable1 = "green;blue" {% list1 = {{ variable1 }}.split(';') %} The grass is {{ list1[0] }} and the boat is {{ list1[1] }} I can split them up before rendering the template but since it are sometimes up to 10 strings inside the string this gets messy. I had a jsp before where I did: <% String[] list1 = val.get("variable1").split(";");%>

Split string into list in jinja?

拈花ヽ惹草 提交于 2021-02-05 13:09:59
问题 I have some variables in a jinja2 template which are strings seperated by a ';'. I need to use these strings separately in the code. i.e. the variable is variable1 = "green;blue" {% list1 = {{ variable1 }}.split(';') %} The grass is {{ list1[0] }} and the boat is {{ list1[1] }} I can split them up before rendering the template but since it are sometimes up to 10 strings inside the string this gets messy. I had a jsp before where I did: <% String[] list1 = val.get("variable1").split(";");%>

Split string into list in jinja?

こ雲淡風輕ζ 提交于 2021-02-05 13:09:55
问题 I have some variables in a jinja2 template which are strings seperated by a ';'. I need to use these strings separately in the code. i.e. the variable is variable1 = "green;blue" {% list1 = {{ variable1 }}.split(';') %} The grass is {{ list1[0] }} and the boat is {{ list1[1] }} I can split them up before rendering the template but since it are sometimes up to 10 strings inside the string this gets messy. I had a jsp before where I did: <% String[] list1 = val.get("variable1").split(";");%>

Split string into list in jinja?

倖福魔咒の 提交于 2021-02-05 13:09:12
问题 I have some variables in a jinja2 template which are strings seperated by a ';'. I need to use these strings separately in the code. i.e. the variable is variable1 = "green;blue" {% list1 = {{ variable1 }}.split(';') %} The grass is {{ list1[0] }} and the boat is {{ list1[1] }} I can split them up before rendering the template but since it are sometimes up to 10 strings inside the string this gets messy. I had a jsp before where I did: <% String[] list1 = val.get("variable1").split(";");%>

python ternary in jinja2 gives TemplateSyntaxError: tag name expected

时光总嘲笑我的痴心妄想 提交于 2021-02-05 02:31:17
问题 I have a table and I want to change background color of tr if value of person.storyPublished is true otherwise do nothing. My code looks like this: {% for person in people %} <tr class="row-person {% '.row-story-published' if person.storyPublished else ' ' %}" > <td> {{ person.name }} </td> ... I get this error: jinja2.exceptions.TemplateSyntaxError TemplateSyntaxError: tag name expected and the CSS part is here: <style> .row-story-published{ background-color: #b3ffb3; } </style> why is this

python ternary in jinja2 gives TemplateSyntaxError: tag name expected

*爱你&永不变心* 提交于 2021-02-05 02:29:36
问题 I have a table and I want to change background color of tr if value of person.storyPublished is true otherwise do nothing. My code looks like this: {% for person in people %} <tr class="row-person {% '.row-story-published' if person.storyPublished else ' ' %}" > <td> {{ person.name }} </td> ... I get this error: jinja2.exceptions.TemplateSyntaxError TemplateSyntaxError: tag name expected and the CSS part is here: <style> .row-story-published{ background-color: #b3ffb3; } </style> why is this

python ternary in jinja2 gives TemplateSyntaxError: tag name expected

ⅰ亾dé卋堺 提交于 2021-02-05 02:29:36
问题 I have a table and I want to change background color of tr if value of person.storyPublished is true otherwise do nothing. My code looks like this: {% for person in people %} <tr class="row-person {% '.row-story-published' if person.storyPublished else ' ' %}" > <td> {{ person.name }} </td> ... I get this error: jinja2.exceptions.TemplateSyntaxError TemplateSyntaxError: tag name expected and the CSS part is here: <style> .row-story-published{ background-color: #b3ffb3; } </style> why is this

python ternary in jinja2 gives TemplateSyntaxError: tag name expected

孤人 提交于 2021-02-05 02:29:23
问题 I have a table and I want to change background color of tr if value of person.storyPublished is true otherwise do nothing. My code looks like this: {% for person in people %} <tr class="row-person {% '.row-story-published' if person.storyPublished else ' ' %}" > <td> {{ person.name }} </td> ... I get this error: jinja2.exceptions.TemplateSyntaxError TemplateSyntaxError: tag name expected and the CSS part is here: <style> .row-story-published{ background-color: #b3ffb3; } </style> why is this

python ternary in jinja2 gives TemplateSyntaxError: tag name expected

半城伤御伤魂 提交于 2021-02-05 02:29:17
问题 I have a table and I want to change background color of tr if value of person.storyPublished is true otherwise do nothing. My code looks like this: {% for person in people %} <tr class="row-person {% '.row-story-published' if person.storyPublished else ' ' %}" > <td> {{ person.name }} </td> ... I get this error: jinja2.exceptions.TemplateSyntaxError TemplateSyntaxError: tag name expected and the CSS part is here: <style> .row-story-published{ background-color: #b3ffb3; } </style> why is this