View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Breno G. de Oliveira > Template-AsGraph > Template::AsGraph



Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  


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


Version 0.01


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;



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.


Breno G. de Oliveira, <garu at>


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


Please report any bugs or feature requests to bug-template-asgraph at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


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

    perldoc Template::AsGraph

You can also look for information at:


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 2009 Breno G. de Oliveira, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: