Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'django.': 0.05; '(so': 0.07; 'thats': 0.07; 'python': 0.09; 'django,': 0.09; 'django': 0.10; '(where': 0.15; 'skip:p 40': 0.15; '1",': 0.16; '2",': 0.16; 'from:addr:r.koebler': 0.16; 'from:name:roland koebler': 0.16; 'received:78.47': 0.16; 'template,': 0.16; 'templating': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'code.': 0.20; 'import': 0.21; 'own.': 0.22; 'example': 0.23; 'least': 0.25; 'header:In-Reply- To:1': 0.25; '-0700,': 0.29; "i'm": 0.29; "skip:' 20": 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'list': 0.35; 'templates': 0.35; 'there': 0.35; 'michael': 0.36; 'charset :us-ascii': 0.36; 'author': 0.37; 'does': 0.37; 'previous': 0.37; 'subject:: ': 0.38; 'several': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'your': 0.60; 'content-disposition:inline': 0.60; 'link': 0.60; 'real': 0.61; 'provide': 0.62; 'more': 0.63; 'choose': 0.65; '2013': 0.84; 'liens': 0.84; 'engines.': 0.91 Date: Tue, 5 Mar 2013 18:16:43 +0100 From: Roland Koebler To: python-list@python.org Subject: Re: Embedding a for inside an html template for substitution References: <1a5a68d8-a97e-4069-a860-c7737dd5a503@googlegroups.com> <6ce88927-ed2f-4045-a23c-033f18cb332a@googlegroups.com> <5134FEB5.4090104@gmail.com> <51356CDE.6050706@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51356CDE.6050706@gmail.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362504186 news.xs4all.nl 6909 [2001:888:2000:d::a6]:60360 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40546 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:
@!title!@
@!e!@
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