HTML-Merge

 view release on metacpan or  search on metacpan

docs/Ext.html  view on Meta::CPAN

<pre>
        name could be 'workers.dat', and the file /data/workers.dat could be:</pre>
<pre>
        worker, salary, office
        Bill, 9999999999999, Redmond
        George, 0, White House</pre>
<p>
</p>
<hr />
<h1><a name="macro_tags">MACRO TAGS</a></h1>
<p>Macro tags define a tag by simply grouping merge code to be susbtituted under 
it. Suppose we have two tags, &lt;$RFIRST&gt; that takes two parameters, and 
&lt;$RSECOND&gt; that takes two as well, we could define the tag &lt;$RCOMBINED&gt;
this way:</p>
<pre>
        sub MACRO_COMBINED ($$$) {
                &lt;&lt;'EOM';
        First $1 and $2: &lt;$RFIRST.$1.$2&gt;&lt;BR&gt;
        Second $2 and $3: &lt;$RSECOND.$2.$3&gt;&lt;BR&gt;
        EOM
        }</pre>
<p>This tag can now be called with three parameters.
Note: You do not need to parse the parameters yourself in a Macro tag.
You need to return a string containing Merge code and references to the
parameters like in a shell script. Writing a prototype is still mandatory.</p>
<p>
</p>
<hr />
<h1><a name="described_tags">DESCRIBED TAGS</a></h1>
<p>Until now, extension tags could be called only with a list of parameters separated by commas. But merge enables defining tags that take a syntax similar to Merge native tags.</p>
<p>Suppose we define a tag:</p>
<pre>
        sub OUT_MINUS ($$) {

docs/Ext.txt  view on Meta::CPAN

                    <$RVAR.worker> has salary <$RVAR.salary><BR>
            </$RCSV>

            name could be 'workers.dat', and the file /data/workers.dat could be:

            worker, salary, office
            Bill, 9999999999999, Redmond
            George, 0, White House

MACRO TAGS
    Macro tags define a tag by simply grouping merge code to be susbtituted
    under it. Suppose we have two tags, <$RFIRST> that takes two parameters,
    and <$RSECOND> that takes two as well, we could define the tag
    <$RCOMBINED> this way:

            sub MACRO_COMBINED ($$$) {
                    <<'EOM';
            First $1 and $2: <$RFIRST.$1.$2><BR>
            Second $2 and $3: <$RSECOND.$2.$3><BR>
            EOM
            }

    This tag can now be called with three parameters. Note: You do not need
    to parse the parameters yourself in a Macro tag. You need to return a
    string containing Merge code and references to the parameters like in a
    shell script. Writing a prototype is still mandatory.

DESCRIBED TAGS
    Until now, extension tags could be called only with a list of parameters
    separated by commas. But merge enables defining tags that take a syntax
    similar to Merge native tags.

    Suppose we define a tag:

lib/HTML/Merge/Compile.pm  view on Meta::CPAN

	{
		my $proto = prototype("HTML::Merge::Ext::MACRO_$tag");
		my $text = quotemeta(&$macro);
		$proto = " ($proto)" if $proto;

		eval <<EOM;
		package HTML::Merge::Ext;

		sub API_$tag$proto 
		{
			Macro("$text", \@_);
		}
EOM
	}

	foreach my $api (qw(API OUT)) 
	{
		my $candidate = "RUN${api}_$tag";
		my $code = UNIVERSAL::can('HTML::Merge::Ext', $candidate);
		if ($code)
		{

lib/HTML/Merge/Compile.pm  view on Meta::CPAN

		}
		$self->{'buffer'} .= &$code($self, $engine, $param);
		if ($printers{$tag}) {
			$self->{'buffer'} .= ");\n";
		}
		return 1;
	}
	undef;
}
#####################################
sub Macro {
	my ($self, $text) = @_;
	my $length = length($self->{'source'});
	my $lennow;

	$self->{'source'} = $text . $self->{'source'};
	for (;;) {
		$lennow = length($self->{'source'});
		last if ($lennow <= $length);
		my $left = $lennow - $length;
		last if $self->{'source'} =~ /^\s{$left}/;

lib/HTML/Merge/Compile.pm  view on Meta::CPAN

		my @c = caller($step);
		$sub = $c[3];
		last if $sub =~ s/^(.*)::Do// && UNIVERSAL::isa($self, $1);
	} 
	$self->Die("Syntax error on $sub: $DB::args[2]");
}


package HTML::Merge::Ext;

sub Macro {
	my $text = shift;
	$text =~ s/(?<!\\)\$(\d+)/\000$_[$1 - 1]\000/g;

	$HTML::Merge::Ext::COMPILER->Macro($text);
	return "";
}

1;

lib/HTML/Merge/Ext.pm  view on Meta::CPAN

	</$RCSV>

	name could be 'workers.dat', and the file /data/workers.dat could be:

	worker, salary, office
	Bill, 9999999999999, Redmond
	George, 0, White House

=head1 MACRO TAGS

Macro tags define a tag by simply grouping merge code to be susbtituted under 
it. Suppose we have two tags, <$RFIRST> that takes two parameters, and 
<$RSECOND> that takes two as well, we could define the tag <$RCOMBINED>
this way:

	sub MACRO_COMBINED ($$$) {
		<<'EOM';
	First $1 and $2: <$RFIRST.$1.$2><BR>
	Second $2 and $3: <$RSECOND.$2.$3><BR>
	EOM
	}

This tag can now be called with three parameters.
Note: You do not need to parse the parameters yourself in a Macro tag.
You need to return a string containing Merge code and references to the
parameters like in a shell script. Writing a prototype is still mandatory.

=head1 DESCRIBED TAGS

Until now, extension tags could be called only with a list of parameters separated by commas. But merge enables defining tags that take a syntax similar to Merge native tags.

Suppose we define a tag:

	sub OUT_MINUS ($$) {

private/perl/HTML/Merge/Compile.pm  view on Meta::CPAN

	{
		my $proto = prototype("HTML::Merge::Ext::MACRO_$tag");
		my $text = quotemeta(&$macro);
		$proto = " ($proto)" if $proto;

		eval <<EOM;
		package HTML::Merge::Ext;

		sub API_$tag$proto 
		{
			Macro("$text", \@_);
		}
EOM
	}

	foreach my $api (qw(API OUT)) 
	{
		my $candidate = "RUN${api}_$tag";
		my $code = UNIVERSAL::can('HTML::Merge::Ext', $candidate);
		if ($code)
		{

private/perl/HTML/Merge/Compile.pm  view on Meta::CPAN

		}
		$self->{'buffer'} .= &$code($self, $engine, $param);
		if ($printers{$tag}) {
			$self->{'buffer'} .= ");\n";
		}
		return 1;
	}
	undef;
}
#####################################
sub Macro {
	my ($self, $text) = @_;
	my $length = length($self->{'source'});
	my $lennow;

	$self->{'source'} = $text . $self->{'source'};
	for (;;) {
		$lennow = length($self->{'source'});
		last if ($lennow <= $length);
		my $left = $lennow - $length;
		last if $self->{'source'} =~ /^\s{$left}/;

private/perl/HTML/Merge/Compile.pm  view on Meta::CPAN

		my @c = caller($step);
		$sub = $c[3];
		last if $sub =~ s/^(.*)::Do// && UNIVERSAL::isa($self, $1);
	} 
	$self->Die("Syntax error on $sub: $DB::args[2]");
}


package HTML::Merge::Ext;

sub Macro {
	my $text = shift;
	$text =~ s/(?<!\\)\$(\d+)/\000$_[$1 - 1]\000/g;

	$HTML::Merge::Ext::COMPILER->Macro($text);
	return "";
}

1;

private/perl/HTML/Merge/Ext.pm  view on Meta::CPAN

	</$RCSV>

	name could be 'workers.dat', and the file /data/workers.dat could be:

	worker, salary, office
	Bill, 9999999999999, Redmond
	George, 0, White House

=head1 MACRO TAGS

Macro tags define a tag by simply grouping merge code to be susbtituted under 
it. Suppose we have two tags, <$RFIRST> that takes two parameters, and 
<$RSECOND> that takes two as well, we could define the tag <$RCOMBINED>
this way:

	sub MACRO_COMBINED ($$$) {
		<<'EOM';
	First $1 and $2: <$RFIRST.$1.$2><BR>
	Second $2 and $3: <$RSECOND.$2.$3><BR>
	EOM
	}

This tag can now be called with three parameters.
Note: You do not need to parse the parameters yourself in a Macro tag.
You need to return a string containing Merge code and references to the
parameters like in a shell script. Writing a prototype is still mandatory.

=head1 DESCRIBED TAGS

Until now, extension tags could be called only with a list of parameters separated by commas. But merge enables defining tags that take a syntax similar to Merge native tags.

Suppose we define a tag:

	sub OUT_MINUS ($$) {

public/template/Repository/build_form.inc  view on Meta::CPAN

<$RSET.__pos_dir__='(uc("<$RVAR.dir>") eq "RTL")?"right":"left"'>

<$REM - Build the Macro hash>
<$RIF.'!"<$RVAR.__loaded__macros__>"'>
	<$R[__macro__].DB='SYSTEM'>
	<$R[__macro__].Q='SELECT name,note FROM tbl WHERE tbl="MACROS" '>
	<$R[__macro__].LOOP>
		<$RSET.__macro_<$R[__macro__].SQL.name>__=' "<$R[__macro__].SQL.note>" '>
	</$R[__macro__].LOOP>
	<$RASSIGN.__loaded__macros__='1'>
</$RIF>

<$REM - Do the page build>

public/template/Repository/build_form_lynx.inc  view on Meta::CPAN

<$RSET.__pos_dir__='(uc("<$RVAR.dir>") eq "RTL")?"right":"left"'>

<$REM - Build the Macro hash>
<$RIF.'!"<$RVAR.__loaded__macros__>"'>
	<$R[__macro__].Q='SELECT name,note FROM tbl WHERE tbl="MACROS" '>
	<$R[__macro__].LOOP>
		<$RSET.__macro_<$R[__macro__].SQL.name>__=' "<$R[__macro__].SQL.note>" '>
	</$R[__macro__].LOOP>
	<$RSET.__loaded__macros__='1'>
</$RIF>

<$REM - Do the page build>



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