Sunday, 12 July 2009

View your templates' structure as a graph

Some very nice visualization tools have emerged on CPAN lately, such as melo++'s MojoX::Routes::AsGraph and franckc++'s CatalystX::Dispatcher::AsGraph. Now, be it Catalyst, Mojolicious, Titanium, Jifty or whatever Perl web framework you use, you most likely use abw++'s amazing Template Toolkit for rendering your site. So I really missed something that would help visualize and untangle the usually complex template structure on a complex website. If you feel that way too, wait no more! :)

use Template::AsGraph

my $graph = Template::AsGraph->graph('mytemplate.tt2');

That's about it. You can also pass TT's configurations and even variables that might mangle with template flow:

Template::AsGraph->graph('template.tt2', \%config, \%vars);

This even lets you get the actual output of the template processing in case you want it as well (you do this with the OUTPUT setting on your config hash, btw).

The result? See for yourself:

Dev code's on github, and the first release should arrive at your local CPAN mirror anytime now.

Let me know what you think!

No comments:

Post a Comment