Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40546
| Date | 2013-03-05 18:16 +0100 |
|---|---|
| From | Roland Koebler <r.koebler@yahoo.de> |
| Subject | Re: Embedding a for inside an html template for substitution |
| References | (1 earlier) <mailman.2845.1362412789.2939.python-list@python.org> <6ce88927-ed2f-4045-a23c-033f18cb332a@googlegroups.com> <CAM1e3vqTujmRtYC1ckjCMt_3gWtBcSOOu==+bB69z5YUdGnMPw@mail.gmail.com> <5134FEB5.4090104@gmail.com> <51356CDE.6050706@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2896.1362504186.2939.python-list@python.org> (permalink) |
Hi,
On Mon, Mar 04, 2013 at 09:22:38AM -0800, Ferrous Cranus wrote:
> can i just put the liens you provided me inside "files.html" and thwy
> will work?
>
> Thats pure pythjon code!
There are several template-engines where you more or less include
python-code into the template, e.g.: empy, mako, pyratemp
On Mon, Mar 04, 2013 at 08:56:14PM -0700, Michael Torrie wrote:
> Check out that link in my previous e-mail to a list of python templating
> engines. Choose one and try it. No I cannot provide any example code.
Here's an example for pyratemp (where I'm the author ;)):
files.html:
<table>
<tr><th>@!title!@</th></tr>
<!--(for e in mylist)-->
<tr><td>@!e!@</td></tr>
<!--(end)-->
</table>
files.py:
import pyratemp
t = pyratemp.Template(filename="files.html")
result = t(title="title ...", mylist=["entry 1", "entry 2", "entry 3"])
print result.encode("ascii", 'xmlcharrefreplace')
On Mon, Mar 04, 2013 at 08:56:14PM -0700, Michael Torrie wrote:
> I do recommend you at least take a look at Django. It may be overkill
> for your needs. It does contain a templating engine,
Last time I tried, the template-engine of Django did not work on its
own. If you need Django-like templates without Django, you can use Jinja.
And if you need a real sandbox (so that you can use untrusted templates),
I would recommend Jinja.
Roland
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Embedding a for inside an html template for substitution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-03-04 07:14 -0800
Re: Embedding a for inside an html template for substitution Michael Torrie <torriem@gmail.com> - 2013-03-04 08:59 -0700
Re: Embedding a for inside an html template for substitution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-03-04 09:22 -0800
Re: Embedding a for inside an html template for substitution Michael Torrie <torriem@gmail.com> - 2013-03-04 20:56 -0700
Re: Embedding a for inside an html template for substitution Roland Koebler <r.koebler@yahoo.de> - 2013-03-05 18:16 +0100
Re: Embedding a for inside an html template for substitution Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-03-04 09:22 -0800
Re: Embedding a for inside an html template for substitution nagia.retsina@gmail.com - 2013-03-04 23:46 -0800
csiph-web