Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40546

Re: Embedding a for inside an html template for substitution

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 <r.koebler@yahoo.de>
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 <r.koebler@yahoo.de>
To python-list@python.org
Subject Re: Embedding a for inside an html template for substitution
References <1a5a68d8-a97e-4069-a860-c7737dd5a503@googlegroups.com> <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>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2896.1362504186.2939.python-list@python.org> (permalink)
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

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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