Mailing List Archive

indenting html
Hi,
this is silly question: can Mason help indenting output html so
that page source at the end looks nicer? :)

Please, apologize, regards, Zdravko
Re: indenting html [ In reply to ]
Hi Zdravko,

You could use a Mason <%filter> block. Inside that block, $_ will be the current output so you can just edit it in-place. You could put this right on the autohandler or inside a template depending on your setup (I do this on element templates to convert them from Markdown myself).

I'm sure there's a CPAN module to do the indenting. If it works on fragments of HTML as well as on entire HTML documents, so much the better.

HTH,
--Greg

Example template:

<html>
... lots of html ...
</html>
<%filter>
$_ = CPAN::Module::to_indent_html($_);
</%filter>

On 2011-08-26, at 7:35 AM, Zdravko Balorda wrote:

> Hi,
> this is silly question: can Mason help indenting output html so
> that page source at the end looks nicer? :)
>
> Please, apologize, regards, Zdravko
Re: indenting html [ In reply to ]
On Aug 26, 2011, at 6:50 AM, Greg Heo wrote:

> You could use a Mason <%filter> block. Inside that block, $_ will be the current output so you can just edit it in-place. You could put this right on the autohandler or inside a template depending on your setup (I do this on element templates to convert them from Markdown myself).
>
> I'm sure there's a CPAN module to do the indenting. If it works on fragments of HTML as well as on entire HTML documents, so much the better.

I tend to just format my Mason templates *just so* to get indenting right. But it's silly.

Thinking about a Template::Declare burner, though…

David