Template::AsGraph - Create a graph from a Template Toolkit file


Template-AsGraph documentation  | view source Contained in the Template-AsGraph distribution.

Index


VERSION

Top

Version 0.01

SYNOPSIS

Top

Given a Template Toolkit filename, it generates a Graph::Easy object with the entire template flow.

  use Template::AsGraph;

  # quick graph creation for any TT2 template
  my $graph = Template::AsGraph->graph('mytemplate.tt2');

  


You can also set up any TT configurations such as different tag styles and INCLUDE_PATHs. You can even set OUTPUT to actually get the processed template (see documentation below):

  my %config = (
        INCLUDE_PATH => 'root/src/',
        START_TAG    => '<+',
        END_TAG      => '+>',
        PLUGIN_BASE  => 'MyApp::Template::Plugin',
        PRE_PROCESS  => 'header',
        OUTPUT       => \$output,
  );
  my $graph = Template::AsGraph->graph('mytemplate.tt2', \%config);

  


Alternatively, if you have dinamically loaded templates, you may want to pass on variables and other TT options just as you would to a regular Template object.

  my $graph = Template::AsGraph->graph('mytemplate.tt2', \%config, \%vars);




The returnerd $graph is a Graph::Easy object, so you can manipulate it at will. For example, save as a PNG file (assuming you have graphviz's "dot" binary)

  if (open my $png, '|-', 'dot -Tpng -o routes.png') {
      print $png $graph->as_graphviz;
      close($png);
  }




DESCRIPTION

Top

graph($template_name)

graph($template_name, \%tt_config)

graph($template_name, \%tt_config, \%tt_vars)

Receives a template name and generates a Graph::Easy object with a representation of the template's flow. It may optionally receive any Template configuration option and variables.

AUTHOR

Top

Breno G. de Oliveira, <garu at cpan.org>

CAVEATS

Top

Although this module should work without any quirks and DWIM for almost everyone, there are some minor issues that can emerge with advanced users:

* In order to correctly find the processing tree, we wrap TT's Context module on our own. So you won't be able to setup a custom Context object to use with this module. If your version also wraps the original TT Context (and you should), you can easily fix this by inheriting from Template::AsGraph::Context instead of from Template::Context, and just setting it up in the config hash:
   CONTEXT => My::Custom::Context->new(),




* If, by any chance, you also want to fetch the output of the processed template(s), you'll need to setup the OUTPUT (and, optionally, OUTPUT_PATH). Please refer to Template::Manual::Config for more information on how to get the best out of it.

BUGS

Top

Please report any bugs or feature requests to bug-template-asgraph at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Template-AsGraph. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Template::AsGraph




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Template-AsGraph

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Template-AsGraph

* CPAN Ratings

http://cpanratings.perl.org/d/Template-AsGraph

* Search CPAN

http://search.cpan.org/dist/Template-AsGraph/

ACKNOWLEDGEMENTS

Top

Andy Wardley and his awesome Template Toolkit deserve all the praise. Also, many thanks to Pedro Melo and his MojoX::Routes::AsGraph, which served as inspiration for this module from the main idea down to the actual code.

COPYRIGHT & LICENSE

Top


Template-AsGraph documentation  | view source Contained in the Template-AsGraph distribution.