matts 2003/01/25 10:10:05
Modified: lib/Apache/AxKit/Language XSP.pm Log: Docs patch from Adam Griffiths Revision Changes Path 1.27 +11 -17 xml-axkit/lib/Apache/AxKit/Language/XSP.pm Index: XSP.pm =================================================================== RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Language/XSP.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- XSP.pm 24 Jan 2003 16:09:25 -0000 1.26 +++ XSP.pm 25 Jan 2003 18:10:05 -0000 1.27 @@ -1516,7 +1516,7 @@ Solution: -use start_expr(), append_to_script(), end_expr(). +use $e->start_expr(), $e->append_to_script(), $e->end_expr(). Example: @@ -1525,7 +1525,7 @@ in parse_start: if ($tag eq 'get-datetime') { - start_expr($e, $tag); # creates a new { ... } block + $e->start_expr($tag); # creates a new { ... } block my $local_format = lc($attribs{format}) || '%a, %d %b %Y %H:%M:%S %z'; return 'my ($format); $format = q|' . $local_format . '|;'; } @@ -1533,8 +1533,8 @@ in parse_end: if ($tag eq 'get-datetime') { - append_to_script($e, 'use Time::Object; localtime->strftime($format);'); - end_expr($e); + $e->append_to_script('use Time::Object; localtime->strftime($format);'); + $e->end_expr(); return ''; } @@ -1543,7 +1543,7 @@ This is more complex than the first 2 examples, so it warrants some explanation. I'll go through it step by step. - start_expr(...) + $e->start_expr($tag) This tells XSP that this really generates a <xsp:expr> tag. Now we don't really generate that tag, we just execute the handler for it. So what @@ -1568,7 +1568,7 @@ (we'll see why we formatted it this way in #5 below). The first thing we get is: - append_to_script($e, 'use Time::Object; localtime->strftime($format);'); + $e->append_to_script('use Time::Object; localtime->strftime($format);'); This does exactly what it says, and the script becomes: @@ -1578,7 +1578,7 @@ Finally, we call: - end_expr($e); + $e->end_expr(); which closes the do {} block, leaving us with: @@ -1591,12 +1591,6 @@ statement executed, which is the C<localtime->strftime()> bit there, thus doing exactly what we wanted. -Note that start_expr, end_expr and append_to_script aren't exported -by default, so you need to do: - - use Apache::AxKit::Language::XSP - qw(start_expr end_expr append_to_script); - =head2 4. Your tag can take as an option either an attribute, or a child tag. Example: @@ -1672,7 +1666,7 @@ in parse_start: if ($tag eq 'get-column') { - start_expr($e, $tag); + $e->start_expr($tag); my $code = 'my ($col);' if ($attribs{col}) { $code .= '$col = q|' . $attribs{col} . '|;'; @@ -1689,8 +1683,8 @@ return ';'; } if ($tag eq 'get-column') { - append_to_script($e, 'Full::Package::get_column($col)'); - end_expr($e); + $e->append_to_script('Full::Package::get_column($col)'); + $e->end_expr(); return ''; }