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


Groups > comp.lang.python > #40459

Re: Embedding a for inside an html template for substitution

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <torriem@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'python': 0.09; 'script,': 0.09; 'template': 0.11; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'marker': 0.16; 'script?': 0.16; 'substituted': 0.16; 'templating': 0.16; 'wrote:': 0.17; 'url:moin': 0.17; 'load': 0.19; 'sort': 0.21; 'parse': 0.22; 'example': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'url:wiki': 0.26; 'am,': 0.27; '(maybe': 0.29; 'cgi': 0.29; 'stuff': 0.30; 'gets': 0.32; 'url:python': 0.32; 'file': 0.32; 'print': 0.32; 'to:addr:python-list': 0.33; 'another': 0.33; 'received:org': 0.36; 'but': 0.36; 'message- id:@gmail.com': 0.36; 'url:org': 0.36; 'data.': 0.36; 'xml': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'instead': 0.39; 'system.': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'skip:" 10': 0.40; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'kind': 0.61
X-Virus-Scanned amavisd-new at torriefamily.org
Date Mon, 04 Mar 2013 08:59:34 -0700
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12
MIME-Version 1.0
To python-list@python.org
Subject Re: Embedding a for inside an html template for substitution
References <1a5a68d8-a97e-4069-a860-c7737dd5a503@googlegroups.com>
In-Reply-To <1a5a68d8-a97e-4069-a860-c7737dd5a503@googlegroups.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
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.2845.1362412789.2939.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1362412789 news.xs4all.nl 6874 [2001:888:2000:d::a6]:41859
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:40459

Show key headers only | View raw


On 03/04/2013 08:14 AM, Ferrous Cranus wrote:
> Instead of writing the above html data inside my html template how
> would i write it with a for that then will be substituted by the
> python script?

What templating system are you using?  Django's?

> can you please write an example for me that user "files.html" and
> gets populates by "files.py" ?

If you're using a CGI script, just use a normal python for loop and
print out the stuff you want using this kind of notation:

for x in xrange(4):
    print "<tr><td>{0}</td></tr>".format(x)


Another alternative is to make your own templating system.  Have it load
and parse the html file (maybe using one of the xml or html parsers),
and substitude some sort of field marker for data.  But that is
re-inventing the wheel.

http://wiki.python.org/moin/Templating

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