最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

google app engine - Is it possible to use jinja values in javascriptjquery functions - Stack Overflow

programmeradmin2浏览0评论

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 badges
Add a ment  | 

1 Answer 1

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).

发布评论

评论列表(0)

  1. 暂无评论