looking at the google web eng example;
{% for greeting in greetings %}
{% if greeting.author %}
<b>{{ greeting.author }}</b> wrote:
{% else %}
An anonymous person wrote:
{% endif %}
<blockquote>{{ greeting.content|escape }}</blockquote>
{% endfor %}
so what i want is: when this iterates, i need to somehow check greeting.author agains some variable that exists in javascript, and then do some other stuff. is it possible to do it?
looking at the google web eng example;
{% for greeting in greetings %}
{% if greeting.author %}
<b>{{ greeting.author }}</b> wrote:
{% else %}
An anonymous person wrote:
{% endif %}
<blockquote>{{ greeting.content|escape }}</blockquote>
{% endfor %}
so what i want is: when this iterates, i need to somehow check greeting.author agains some variable that exists in javascript, and then do some other stuff. is it possible to do it?
Share Improve this question asked Feb 17, 2013 at 6:09 btevfikbtevfik 3,4313 gold badges29 silver badges40 bronze badges1 Answer
Reset to default 5{% for greeting in greetings %}
{% if greeting.author %}
<b>{{ greeting.author }}</b> wrote:
{% else %}
An anonymous person wrote:
{% endif %}
<blockquote>{{ greeting.content|escape }}</blockquote>
<script type="text/javascript">
var greeting_author = "{{ greeting.author }}";
if(greeting_author === someVariable){
// do other stuff here
}
</script>
{% endfor %}
Basically, you can just print the variable as js. Keep the type in mind (for example put ""
around them for strings).