Last active
August 29, 2015 14:27
-
-
Save horacioibrahim/9e50da300823e92a6845 to your computer and use it in GitHub Desktop.
dom-bind instead variable of template (Jinja2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- ... omitted ... --> | |
| <body> | |
| <!-- | |
| In this case, I have passed variable of template in the attributes of the element sc-navbar. | |
| NOTE: I did change of '{{' to '%%' for display the variables from Flask template engine. This help us | |
| to see difference of the Flask for Polymer scopes. | |
| I'm using g (global variable) of the Flask (see more: http://flask.pocoo.org/docs/0.10/templating/#standard-context) | |
| --> | |
| <sc-navbar username="%% g.user.shortname %%" avatar="%% g.user.md5_email %%" online="%% g.user.status_online %%"></sc-navbar> | |
| </body> | |
| <!-- ... changes ... --> | |
| <body> | |
| <!-- | |
| So to avoid this approach very linked with the Template Engine of the backend. I changed to: | |
| (Basically, I built a view to return user's data as JSON) | |
| --> | |
| <template is="dom-bind"> | |
| <core-ajax url="http://app.example.com/views/user/me" lastresponse="{{userData}}"></core-ajax> | |
| <sc-navbar username="{{userData.username}}" avatar="{{userData.md5_email}}" online="{{userData.status_online}}"></sc-navbar> | |
| </template> | |
| </body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment