HTML-YaTmpl

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

       22  </:for>

      Line 1 defines a macro named "td" that prints one HTML table cell. It
      uses the variable "val". Lines 2 to 9 define a macro called "tr" that
      implements a table row. It is designed to be used in a substitution
      scope as it assigns the current value "<:/>" to a variable "x" to
      build a "<:for>" scope. In line 3 the macro defined in line 1 is used
      twice, once as "<:m/>" and once as "<:macro>". Then in line 21 the
      "tr" macro is invoked and generates all table rows.

      Macros are bound to a "HTML::YaTmpl" instance. That means you can
      define a set of macros in one template, evaluate it and then evaluate
      another template with the same instance using macros defined in the
      first template.

    <:set></:set>
      is used to make up the parameter list for "<:for>", "<:eval>",
      "<:include>" and "<:macro>" statements. Outside one of these scopes or
      inside a "<:code>" segment "<:set>" can be used to manipulate the
      current parameter list.

lib/HTML/YaTmpl.pm  view on Meta::CPAN

    return $I->_eval_list( $v, $nh, $I->__get_code_list($el) );
  } elsif( $el->[1] eq 'm' or $el->[1] eq 'macro' ) { # invoke macro
    my $macro;
    foreach my $f (@{$el->[2]}) {
      if( !ref($f) and length($f) ) {
	$macro=$I->_eval_list( $v, $h, $I->_parse_cached($f) );
	last;
      }
    }
    unless( exists $I->_macros->{$macro} ) {
      return $I->_report_error( "<:macro $macro>", "Macro not defined" );
    }
    $macro=$I->_macros->{$macro};
    my $nh=+{$I->_make_include_param_list( $v, $el, $h )};
    #warn "M M M: ";
    #use Data::Dumper; warn Dumper($nh);
    return $I->_eval_list( $v, $nh, @{$macro} );
  } elsif( $el->[1] eq 'eval' ) {
    my $nh=+{$I->_make_include_param_list( $v, $el, $h )};
    my $new_tmpl=$I->_eval_list( $v, $nh, $I->__get_code_list($el) );
    #warn "new_tmpl: $new_tmpl\n";

lib/HTML/YaTmpl.pod  view on Meta::CPAN

 22  </:for>

Line 1 defines a macro named C<td> that prints one HTML table cell. It uses
the variable C<val>. Lines 2 to 9 define a macro called C<tr> that
implements a table row. It is designed to be used in a substitution scope
as it assigns the current value C<< <:/> >> to a variable C<x> to build
a C<< <:for> >> scope. In line 3 the macro defined in line 1 is used twice,
once as C<< <:m/> >> and once as C<< <:macro> >>. Then in line 21 the C<tr>
macro is invoked and generates all table rows.

Macros are bound to a C<HTML::YaTmpl> instance. That means you can define a
set of macros in one template, evaluate it and then evaluate another template
with the same instance using macros defined in the first template.

=item B<< <:set></:set> >>

is used to make up the parameter list for C<< <:for> >>, C<< <:eval> >>,
C<< <:include> >> and C<< <:macro> >> statements. Outside one of these
scopes or inside a C<< <:code> >> segment C<< <:set> >> can be used to
manipulate the current parameter list.



( run in 0.526 second using v1.01-cache-2.11-cpan-49f99fa48dc )