Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Output well-formatted HTML in jinja2
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
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:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Cosmia Luna  
View profile  
 More options Feb 4 2012, 3:48 pm
From: Cosmia Luna <cosm...@gmail.com>
Date: Sat, 4 Feb 2012 12:48:44 -0800 (PST)
Local: Sat, Feb 4 2012 3:48 pm
Subject: Output well-formatted HTML in jinja2

It's very difficult to manage the whitespaces in template by '-' mark, and
usually makes the template difficult to read when try to output indented
HTML. It's of little use in production environment, but very useful
in development environment. I tried pytidylib but tidy can only filter
XHTML and HTML4 or before, it replaced my '<!DOCTYPE html>' (html5) with
its one and CORRECT something but valid.

How can I just re-indent the HTML without the correction? The input HTML
is guaranteed valid.

Thanks

Cosmia


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Sapin  
View profile  
 More options Feb 4 2012, 6:19 pm
From: Simon Sapin <simon.sa...@exyr.org>
Date: Sun, 05 Feb 2012 00:19:53 +0100
Local: Sat, Feb 4 2012 6:19 pm
Subject: Re: Output well-formatted HTML in jinja2
Le 04/02/2012 21:48, Cosmia Luna a crit :

> It's very difficult to manage the whitespaces in template by '-' mark,
> and usually makes the template difficult to read when try to output
> indented HTML. It's of little use in production environment, but very
> useful in development environment. I tried pytidylib but tidy can only
> filter XHTML and HTML4 or before, it replaced my '<!DOCTYPE html>'
> (html5) with its one and CORRECT something but valid.

> How can I just re-indent the HTML without the correction? The input HTML
> is guaranteed valid.

Hi,

I tried quite a few thing to do that, from careful usage of '-' as you
say, to Jinja2 macros that re-indented stuff. I eventually gave up.

In production, the only concern is file size but if you use gzip the
difference is negligible. (Or not worth the complexity, IMO.) In
development, I find that I use Firebug much more than view source. In
other words, I care about the parsed DOM, not the HTML.

So the only remaining thing to optimize for is source (template)
readability. I try to generally indent both Jinja blocks and HTML elements.

Regards,
--
Simon Sapin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Armin Ronacher  
View profile  
 More options Feb 5 2012, 5:15 am
From: Armin Ronacher <armin.ronac...@active-4.com>
Date: Sun, 05 Feb 2012 11:15:29 +0100
Local: Sun, Feb 5 2012 5:15 am
Subject: Re: Output well-formatted HTML in jinja2
Just one question:

On 2/4/12 9:48 PM, Cosmia Luna wrote:

> How can I just re-indent the HTML without the correction? The input HTML
> is guaranteed valid.

Why?

Regards,
Armin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cosmia Luna  
View profile  
 More options Feb 5 2012, 8:42 pm
From: Cosmia Luna <cosm...@gmail.com>
Date: Sun, 5 Feb 2012 17:42:35 -0800 (PST)
Local: Sun, Feb 5 2012 8:42 pm
Subject: Re: Output well-formatted HTML in jinja2

Sure it's of little use in production environment, but useful
in development environment to debug the final html and find what's broken
if there is.

Regards,

Cosmia


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven Kryskalla  
View profile  
 More options Feb 5 2012, 10:45 pm
From: Steven Kryskalla <skryska...@gmail.com>
Date: Sun, 5 Feb 2012 19:45:36 -0800
Local: Sun, Feb 5 2012 10:45 pm
Subject: Re: Output well-formatted HTML in jinja2

On Sun, Feb 5, 2012 at 5:42 PM, Cosmia Luna <cosm...@gmail.com> wrote:
> Sure it's of little use in production environment, but useful
> in development environment to debug the final html and find what's broken if
> there is.

There are some solutions here:

http://stackoverflow.com/questions/6150108/python-how-to-pretty-print...

You could wrap one of those (e.g. BeautifulSoup.prettify) around your
template output or around your app as middleware (if this is for a web
app).

-steve


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cosmia Luna  
View profile  
 More options Feb 6 2012, 6:37 pm
From: Cosmia Luna <cosm...@gmail.com>
Date: Mon, 6 Feb 2012 15:37:43 -0800 (PST)
Local: Mon, Feb 6 2012 6:37 pm
Subject: Re: Output well-formatted HTML in jinja2

Thanks, this is really what I want.

Regards,

Cosmia


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »