Indent HTML Tags Within Template

38 views
Skip to first unread message

Sean Law

unread,
Nov 2, 2016, 4:22:20 PM11/2/16
to Tornado Web Server
Is there a way to ensure that my template maintains its tag indentation:

<div>
    <h1>{{ title }}</h2>
    {% if 'content' in globals() %}
    <div>
        <p>{{ content }}</p>
    </div>
    {% end %}
</div>

Right now, everything is left justified along with blank lines

<div>
<h1>SOME TITLE</h2>

<div>
<p>SOME CONTENT</p>
</div>

</div>

Gavin M. Roy

unread,
Nov 2, 2016, 4:25:39 PM11/2/16
to python-...@googlegroups.com
You could probably extend RequestHandler.write inspecting the content type and running the content being written through tidy before writing it...


--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornado+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Japhy Bartlett

unread,
Nov 2, 2016, 4:33:01 PM11/2/16
to python-...@googlegroups.com
The template class has params for handling whitespace stripping: 




Sounds like you basically just want to turn it off!

- Japhy

A. Jesse Jiryu Davis

unread,
Nov 2, 2016, 4:34:44 PM11/2/16
to python-...@googlegroups.com
Right, create your Application like:

Application(... args ..., template_whitespace="all")
>>> email to python-tornad...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Tornado Web Server" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to python-tornad...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Tornado Web Server" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python-tornad...@googlegroups.com.

Sean Law

unread,
Nov 2, 2016, 8:45:40 PM11/2/16
to Tornado Web Server
Thanks! That did the trick
Reply all
Reply to author
Forward
0 new messages