Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43015
| From | Cousin Stanley <cousinstanley@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: can anyone help me in developing a simple webpage in jinja2 |
| Date | 2013-04-07 19:29 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <kjshej$kg8$1@dont-email.me> (permalink) |
| References | <e8c498f4-348c-415f-927c-f871551d9a82@googlegroups.com> |
Satabdi Mukherjee wrote:
> i am a rookie in python and i am trying
> to develop a simple webpage using jinja2.
>
> can anyone please help me how to do that
You might try using your jinja template
with named tuples ....
# -------------------------------------------
from jinja2 import Template
from collections import namedtuple as NT
nt = NT( 'Navigation' , 'href caption' )
n1 = nt( 'http://python.org' , 'python' )
n2 = nt( 'http://cython.org' , 'cython' )
n3 = nt( 'http://jython.org' , 'jython' )
n4 = nt( 'http://pypy.org/' , 'pypy' )
nav = ( n1 , n2 , n3 , n4 )
tmpl = Template( '''\
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<title>My Webpage</title>
</head>
<body>
<ul id="navigation">
{% for url , caption in navigation %}
<li><a href="{{ url }}">{{ caption }}</a></li>
{% endfor %}
</ul>
<h1>My Webpage</h1>
{{ a_variable }}
</body>
</html>
''' )
print tmpl.render(
variable = 'Navigation' , navigation = nav )
--
Stanley C. Kitching
Human Being
Phoenix, Arizona
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
can anyone help me in developing a simple webpage in jinja2 Satabdi Mukherjee <satamukh@gmail.com> - 2013-04-05 15:41 -0700 Re: can anyone help me in developing a simple webpage in jinja2 Jan Riechers <janpeterr@freenet.de> - 2013-04-06 10:15 +0300 Re: can anyone help me in developing a simple webpage in jinja2 Chris Angelico <rosuav@gmail.com> - 2013-04-06 19:00 +1100 Re: can anyone help me in developing a simple webpage in jinja2 Cousin Stanley <cousinstanley@gmail.com> - 2013-04-07 19:29 +0000
csiph-web