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


Groups > comp.lang.python > #40469

Re: Embedding a for inside an html template for substitution

Newsgroups comp.lang.python
Date 2013-03-04 09:22 -0800
References <1a5a68d8-a97e-4069-a860-c7737dd5a503@googlegroups.com> <mailman.2845.1362412789.2939.python-list@python.org>
Subject Re: Embedding a for inside an html template for substitution
From Ferrous Cranus <nikos.gr33k@gmail.com>
Message-ID <mailman.2852.1362417767.2939.python-list@python.org> (permalink)

Show all headers | View raw


Τη Δευτέρα, 4 Μαρτίου 2013 5:59:34 μ.μ. UTC+2, ο χρήστης Michael Torrie έγραψε:
> 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



Firstly thank you for your answer, but iam a bit confised.

can i just put the liens you provided me inside "files.html" and thwy will work?

Thats pure pythjon code!

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

wont html complain?

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