File under "ought to have been written ten years ago", but oh well:

    https://metacpan.org/module/masontidy

masontidy tidies the Perl code embedded in Mason components. It works with 
%-lines, <% %> tags, and the various Perl blocks, in both Mason 1 and Mason 2 
syntax.

It does not (yet) attempt to tidy the HTML or other non-Perl content in a 
component.

See below for an example. Please give it a try (make sure you have backup!) and 
let me know of problems.

Best
Jon

-----

BEFORE:

    %if($contents||$allow_empty) {
      <ul>
    %foreach my $line (@lines) {
      <li><%2+(3-4)*6%></li>
      <li><%  foo($.bar,$.baz,  $.bleah)%></li>
    %}
      </ul>
    %}

    <%init>
    my @articles = 
@{Blog::Article::Manager->get_articles(sort_by=>"create_time",limit=>5)};
    </%init>

AFTER:

    % if ( $contents || $allow_empty ) {
      <ul>
    %   foreach my $line (@lines) {
      <li><% 2 + ( 3 - 4 ) * 6 %></li>
      <li><% foo( $.bar, $.baz, $.bleah) %></li>
    %   }
      </ul>
    %}

    <%init>
    my @articles =
      @{ Blog::Article::Manager->get_articles
         ( sort_by => "create_time", limit => 5 ) };
    </%init>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to