Template::Alloy::Parse

Template::Alloy::Parse is a Perl module with common parsing role for creating AST from templates.
Download

Template::Alloy::Parse Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Paul Seamons
  • Publisher web site:
  • http://search.cpan.org/~rhandom/

Template::Alloy::Parse Tags


Template::Alloy::Parse Description

Template::Alloy::Parse is a Perl module with common parsing role for creating AST from templates. Template::Alloy::Parse is a Perl module with common parsing role for creating AST from templates.The Template::Alloy::Parse role is reponsible for storing the majority of directive parsing code, as well as for delegating to the TT, HTE, Tmpl, and Velocity roles for finding variables and directives.ROLE METHODSparse_treeUsed by load_tree. This is the main grammar engine of the program. It delegates to the syntax found in $self->{'SYNTAX'} (defaults to 'alloy') and calls the function found in the $SYNTAX hashref. The majority of these syntaxes use methods found in the $DIRECTIVES hashref to parse different DIRECTIVE types for each particular syntax.A template that looked like the following: Foo Barwould parse to the following AST: ], ], 'Bar', ]The "GET" words represent the directive used. The 6, 15 represent the beginning and ending characters of the directive in the document. The remaining items are the variables necessary for running the particular directive.parse_exprUsed to parse a variable, an expression, a literal string, or a number. It returns a parsed variable tree. Samples of parsed variables can be found in the VARIABLE PARSE TREE section. my $str = "1 + 2 * 3"; my $ast = $self->parse_expr($str); # $ast looks like , 0]], 0]parse_argsAllow for the multitudinous ways that TT parses arguments. This allows for positional as well as named arguments. Named arguments can be separated with a "=" or "=>", and positional arguments should be separated by " " or ",". This only returns an array of parsed variables. To get the actual values, you must call play_expr on each value.dump_parse_treeThis method allows for returning a string of perl code representing the AST of the parsed tree.It is mainly used for testing.dump_parse_exprThis method allows for returning a Data::Dumper dump of a parsed variable. It is mainly used for testing.parse_*Methods by these names are used by parse_tree to parse the template. These are the grammar. They are used by all of the various template syntaxes Unless otherwise mentioned, these methods are not exposed via the role.Requirements:· Perl Requirements: · Perl


Template::Alloy::Parse Related Software