The expansion of {{article.title}} is done by the jinja2 template engine on
the server before the javascript is executed on the client (i.e., the
browser). So the fact you're using javascript to display the value is not
relevant. Either GAE is affecting jinja2 behavior or your "article" object
doesn't have a "title" attribute or member (if it's a dict like object) or
the value isn't what you expect. Try embedding the following in your
document:
<!--
{{'%r'|format(article)}}
-->
That will embed a python representation of the "article" object as a
comment in the document. Then use your brower "view page source" command to
see what was embedded. For example, I did this for one of my objects and
got this:
<!--
{'last_changed_rfc3339': '2014-03-24T15:04:01Z',
'last_changed_rfc822': 'Mon, 24 Mar 2014 15:04:01 GMT',
...
-->
Note that the ' is a single-quote, which if you make the substitution
yields the more familiar:
{'last_changed_rfc3339': '2014-03-24T15:04:01Z',
'last_changed_rfc822': 'Mon, 24 Mar 2014 15:04:01 GMT',
On Mon, Mar 24, 2014 at 7:31 AM, alex <[email protected]> wrote:
> Hi guys,
>
> What i want like below:
> ---
> <script type="text/javascript">
> alert({{article.title}});
> </script>
> ---
> this code block was writen in some.html using jinja2 template, working by
> GAE.
> it alert nothing, empty content on dialog.
> if I take the code below instead,it work fine:(but need pass extra
> variable article.title as "title")
> ---
> <script type="text/javascript">
> alert({{title}});
> </script>
> ---
>
> so 1. ,jinja/jinja2 could only pass int, bool, and so on(these regular
> type), isn't it?
> 2. if I want pass the instance "article", do I must dump it by json?
> 3. Is any other way for code like article.title that passing to javascript?
> (some times i think this problem may be less relate with javascript.)
>
> thx,
>
> --
> You received this message because you are subscribed to the Google Groups
> "pocoo-libs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/pocoo-libs.
> For more options, visit https://groups.google.com/d/optout.
>
--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pocoo-libs.
For more options, visit https://groups.google.com/d/optout.