Carl Karsten wrote:
> nicely formated template code generates lots of CRs in the resulting html.  I 
> am 
> trying to figure out how to make the html a bit easier to read.
> 
> for instance, how can I make this:
> 
> <td{% if not day.in_month %} class="cal_not_in_month"{% endif %}
> {% ifequal day.day day.today %} class="today"{% endifequal %}>
> 
> Not put the CR inside the <td> ?
> 
> I realize i may be asking for magic, but I am thinking maybe something like 
> skip 
> the CR for lines ending with %}

I used something like this once. However, you should think twice before
adding it on a busy site.

from BeautifulSoup import BeautifulSoup

class BeautifulSoupPrettifyMiddleware(object):

    def process_response(self, request, response):

        if 'text/html' in response['Content-Type']:

            soup = BeautifulSoup(response.content)
            response.content = soup.prettify()

        return response

-- 
Christian Joergensen | Linux, programming or web consultancy
http://www.razor.dk  |     Visit us at: http://www.gmta.info

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to