+ CGI::Ex::Template->define_vmethod(
+ 'text',
+ reverse => sub { my $item = shift; return scalar reverse $item },
+ );
+
+=item C<register_function>
+
+This is the HTML::Template way of defining text vmethods. It is the same as
+calling define_vmethod with "text" as the first argument.
+
+ CGI::Ex::Template->register_function(
+ reverse => sub { my $item = shift; return scalar reverse $item },
+ );
+
+=item C<define_directive>
+
+This method can be used for adding new directives or overridding existing
+ones.
+
+ CGI::Ex::Template->define_directive(
+ MYDIR => {
+ parse_sub => sub {}, # parse additional items in the tag
+ play_sub => sub {
+ my ($self, $ref, $node, $out_ref) = @_;
+ $$out_ref .= "I always say the same thing!";
+ return;
+ },
+ is_block => 1, # is this block like
+ is_postop => 0, # not a post operative directive
+ no_interp => 1, # no interpolation in this block
+ continues => undef, # it doesn't "continue" any other directives
+ },
+ );
+
+Now with a template like:
+
+ my $str = "([% MYDIR %]This is something[% END %])";
+ CGI::Ex::Template->new->process(\$str);
+
+You will get:
+
+ (I always say the same thing!)
+
+We'll add more details in later revisions of this document.
+
+=item C<define_syntax>
+
+This method can be used for adding other syntaxes to or overridding
+existing ones in the list of choices available in CET. The syntax can
+be chosen by the SYNTAX configuration item.
+
+ CGI::Ex::Template->define_syntax(
+ my_uber_syntax => sub {
+ my $self = shift;
+ local $self->{'V2PIPE'} = 0;
+ local $self->{'V2EQUALS'} = 0;
+ local $self->{'PRE_CHOMP'} = 0;
+ local $self->{'POST_CHOMP'} = 0;
+ local $self->{'NO_INCLUDES'} = 0;
+ return $self->parse_tree_tt3(@_);
+ },
+ );
+
+The subroutine that is used must return an opcode tree (AST) that
+can be played by the execute_tree method.
+
+=item C<define_operator>
+
+This method allows for adding new operators or overriding existing ones.
+
+ CGI::Ex::Template->define_operator({
+ type => 'right', # can be one of prefix, postfix, right, left, none, ternary, assign
+ precedence => 84, # relative precedence for resolving multiple operators without parens
+ symbols => ['foo', 'FOO'], # any mix of chars can be used for the operators
+ play_sub => sub {
+ my ($one, $two) = @_;
+ return "You've been foo'ed ($one, $two)";
+ },
+ });
+
+You can then use it in a template as in the following:
+
+ my $str = "[% 'ralph' foo 1 + 2 * 3 %]";
+ CGI::Ex::Template->new->process(\$str);
+
+You will get:
+
+ You've been foo'ed (ralph, 7)
+
+Future revisions of this document will include more samples.
+