Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need variable assignment in template #50

Closed
yashh opened this issue Jan 1, 2010 · 2 comments
Closed

Need variable assignment in template #50

yashh opened this issue Jan 1, 2010 · 2 comments

Comments

@yashh
Copy link

yashh commented Jan 1, 2010

I have a huge json string in my template and I am using

{{ json_decode(json_string)["name"] }}

similarly to render other attributes I am calling json_decode everytime. Is there a way I can assign the output of the json_decode operation to a variable?

{% data_dict = json_decode(json_string) %}

I get ParseError: unknown operator: 'data_dict'.
Any work arounds?

@Bessonov
Copy link

Try:

{% set data_dict = json_decode(json_string) %}

@yashh
Copy link
Author

yashh commented Jan 17, 2010

awesome. just started reading template.py, there quite many tags template supports. Cool!

jeethu referenced this issue in jeethu/cyclone Jun 11, 2012
realtime graphical statistics to websocket chat example (as requested on fiorix#50)
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants