some blank line in template.
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
simon <hapm... @gmail.com>
Date: Thu, 26 Jul 2012 08:50:29 -0700 (PDT)
Local: Thurs, Jul 26 2012 11:50 am
Subject: some blank line in template.
The tornado's template make many blank line ,especially in the iteration.How to do better.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Russ Weeks <rwe... @newbrightidea.com>
Date: Thu, 26 Jul 2012 09:50:23 -0700
Local: Thurs, Jul 26 2012 12:50 pm
Subject: Re: [tornado] some blank line in template.
Hi, Simon,
Does your template file end with ".html" or ".js"? If so, I think Tornado
will compress whitespace automatically.
-Russ
On Thu, Jul 26, 2012 at 8:50 AM, simon <hapm
... @gmail.com> wrote:
> The tornado's template make many blank line ,especially in the iteration.How
> to do better.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
simon <hapm... @gmail.com>
Date: Thu, 26 Jul 2012 10:19:23 -0700 (PDT)
Local: Thurs, Jul 26 2012 1:19 pm
Subject: Re: [tornado] some blank line in template.
Hi Russ My template file end is with ".html". I can't delete all end of line in the code. Don't you have this problem? This tornado's version is 2.1.
simon
On Friday, July 27, 2012 12:50:23 AM UTC+8, Russ Weeks wrote:
> Hi, Simon,
> Does your template file end with ".html" or ".js"? If so, I think Tornado > will compress whitespace automatically.
> -Russ
> On Thu, Jul 26, 2012 at 8:50 AM, simon <hapm... @gmail.com> wrote:
>> The tornado's template make many blank line ,especially in the iteration.How >> to do better.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
simon <hapm... @gmail.com>
Date: Thu, 26 Jul 2012 11:05:34 -0700 (PDT)
Local: Thurs, Jul 26 2012 2:05 pm
Subject: Re: some blank line in template.
Hi,guys
I have a test.this prove my problem.
this code: //=========================================== import tornado.ioloop import tornado.web class MainHandler(tornado.web.RequestHandler): def get(self): self.render("test.html") application=tornado.web.Application([ (r"/",MainHandler), ]) if __name__ == "__main__": application.listen(8000) tornado.ioloop.IOLoop.instance().start() //===========================================
the html file "test.html" //=========================================== <html> <head> </head> <body> test1 test2 {%for i in range(0,10)%} {%if i%2==0 %} <br>test {%end%} {%end%} </body> </html> //===========================================
the Result: //============================================ <html><head></head><body>test1test2
<br>test
<br>test
<br>test
<br>test
<br>test
</body>
</html>
//=============================================
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Lorenzo Bolla <lbo... @gmail.com>
Date: Fri, 27 Jul 2012 10:45:30 +0100
Local: Fri, Jul 27 2012 5:45 am
Subject: Re: [tornado] Re: some blank line in template.
This is a feature! ;-)
The fact is that the template syntax, although it resemble Python's, does
not actually rely on newlines and indentation to define blocks. Therefore,
any newline at the end of, let's say, {% for... %} or {% if %} is still
considered a valid character and printed in the result.
To achieve what you want (but why do you want it, anyway?), you can do this:
<html>
<head>
</head>
<body>
test1
test2{%for i in range(0,10)%}{%if i%2==0 %}
<br>test{%end%}{%end%}
</body>
</html>
L.
On Thu, Jul 26, 2012 at 7:05 PM, simon <hapm
... @gmail.com> wrote:
> Hi,guys
> I have a test.this prove my problem.
> this code:
> //===========================================
> import tornado.ioloop
> import tornado.web
> class MainHandler(tornado.web.RequestHandler):
> def get(self):
> self.render("test.html")
> application=tornado.web.Application([
> (r"/",MainHandler),
> ])
> if __name__ == "__main__":
> application.listen(8000)
> tornado.ioloop.IOLoop.instance().start()
> //===========================================
> the html file "test.html"
> //===========================================
> <html>
> <head>
> </head>
> <body>
> test1
> test2
> {%for i in range(0,10)%}
> {%if i%2==0 %}
> <br>test
> {%end%}
> {%end%}
> </body>
> </html>
> //===========================================
> the Result:
> //============================================
> <html><head></head><body>test1test2
> <br>test
> <br>test
> <br>test
> <br>test
> <br>test
> </body>
> </html>
> //=============================================
You must
Sign in before you can post messages.
You do not have the permission required to post.