I find usefull, when developing web pages in a WYSIWYG environment, to show an example text for placeholder where HTML::Template replace dynamic text with TMPL_VAR tag.
I create this patch to support a <TMPL_VAR ....>this is a placeholder text and here i can write whatever i want</TMPL_VAR> structure to visual formatting an placing dynamic text that HTML::Template then replace using TMPL_VAR tag. The patch also add a template file and a test step to check this new structure. Save the patch ad apply with "patch -p1 < nameofpatch.patch" before build the module. Hoping Tregar add this patch in the next release of HTML::Template. Best regards. ------------------------------------------------------------ + Dott. Bruni Emiliano - Graduated in Physics + ------------------------------------------------------------ + Cisco Certificated Designer Associate + + Software developer & Network Administrator + + Nick Handle: EB1346-RIPE BE1484 ICQ: #16774468 + + E-Mail: [EMAIL PROTECTED] + + Web: http://www.ebruni.it + +----------------------------------------------------------+ ---- Cut here and save with HTML-Template-2.5-slash-var.patch filename ---- --- /usr/src/HTML-Template-2.5/Template.pm Sat Feb 2 00:01:37 2002 +++ HTML-Template-2.5/Template.pm Tue Mar 12 09:43:49 2002 @@ -1723,6 +1723,16 @@ $options->{vanguard_compatibility_mode} and $self->{template} =~ s/%([-\w\/\.+]+)%/<TMPL_VAR NAME=$1>/g; + # handle the <TMPL_VAR>....</TMPL_VAR> structure + $self->{template} =~ s{ + (<\s* # first < + [Tt][Mm][Pp][Ll]_[Vv][Aa][Rr] # apply to TMPL_VAR tag only + .*?>) # this is HTML::Template tag ($1) + ((.*?) # deleting all after here + <\s*\/ # if there is the </TMPL_VAR> tag + [Tt][Mm][Pp][Ll]_[Vv][Aa][Rr] + \s*>)?}{$1}gmsx; + # now split up template on '<', leaving them in my @chunks = split(m/(?=<)/, $self->{template}); --- /usr/src/HTML-Template-2.5/templates/simple-slash-var.tmpl Thu Jan 1 01:00:00 1970 +++ HTML-Template-2.5/templates/simple-slash-var.tmpl Tue Mar 12 09:56:31 2002 @@ -0,0 +1,9 @@ +<HTML> +<HEAD> +<TITLE> +Simple Template with <TMPL_VAR>...</TMPL_VAR> tag +</TITLE> +<BODY> +I am a <TMPL_VAR NAME="ADJECTIVE">this is a placeholder</TMPL_VAR> simple template. +</BODY> +</HTML> --- /usr/src/HTML-Template-2.5/test.pl Tue Jan 29 05:03:46 2002 +++ HTML-Template-2.5/test.pl Tue Mar 12 09:55:01 2002 @@ -3,7 +3,7 @@ use strict; use Test; -BEGIN { plan tests => 55 }; +BEGIN { plan tests => 56 }; use HTML::Template; ok(1); @@ -20,6 +20,17 @@ $template->param('ADJECTIVE', 'very'); $output = $template->output; ok($output !~ /ADJECTIVE/ and $template->param('ADJECTIVE') eq 'very'); + +# test a simple template with <TMPL_VAR>...</TMPL_VAR> structure +$template = HTML::Template->new( + path => 'templates', + filename => 'simple-slash-var.tmpl', + debug => 0 + ); + +$template->param('ADJECTIVE', 'very'); +$output = $template->output; +ok($output !~ /ADJECTIVE/ and $output !~ /placeholder/ and $template->param('ADJECTIVE') eq 'very'); # try something a bit larger $template = HTML::Template->new( --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
