Hello
Aim: Retrieve list of variables in a template.
Example:
#base_page.html
<!doctype html>
<html>
<head>
<title> {{title}}</title>
{% block stylesheet %}
{% endblock %}
{% block javascript %}
{% endblock %}
</head>
<body>
<section class="enitre_page">
<section class ="site_header">
</section>
{% block page_header %}
{% endblock %}
{% block content %}
{% endblock %}
{% block comments %}
{% endblock %}
<section class="site_footer">
</section>
</section>
</body>
</html>
#page_content.html
{% extends base_page.html %}
{% block content %}
{{ contents }}
{% for x in contents %}
{{ x }}
{% endfor %}
{% endblock %}
In this case expected output is title, contents.
I tried the following snippet
env = Environment(loader=PackageLoader('package', 'templates'), template =
env.get_template('page_content.html') ,
env.parse(template).find_all(nodes.KeyWord).next()
Output
Traceback (most recent call last):
File "<pyshell#28>", line 3, in <module>
env.parse(template).find_all(nodes.Keyword).next()
StopIteration
So my understanding is for is keyword I should get the output.
Note: Main intention is get list of variables like {{ name }} and contents
in {% for x in contents %}
Thanks
Kracekumar
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/pocoo-libs/-/9TNIU0U53AUJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en.