X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=general%2Finterpolate_fancy;fp=general%2Finterpolate_fancy;h=2c79e8ea1c4525c6c3ad78da0afca1e519fdce7f;hb=29211a57ae6826974c034d8c347af4e13aa56467;hp=9810785109f6e1ae628a64f81f333cd38d0a1003;hpb=b462f96afce66566689b86180abdca0e8f86f0dd;p=matthijs%2Fupstream%2Fblosxom-plugins.git diff --git a/general/interpolate_fancy b/general/interpolate_fancy index 9810785..2c79e8e 100644 --- a/general/interpolate_fancy +++ b/general/interpolate_fancy @@ -175,8 +175,16 @@ sub _action { $blosxom::plugins{$plugin} > 0 and $plugin->can($action) and $result = $plugin->$action($attributes, $content); - - return $attributes->{'output'} =~ /yes/i ? $result : undef; + + # Optionally interpolate and/or output the result, if requested. + if ($attributes->{'output'} =~ /yes/i) { + if ($attributes->{'interpolate'} =~ /yes/i) { + $result = interpolate_fancy::do_interpolate($result); + } + return $result; + } else { + return undef; + } } sub _attributes { @@ -305,6 +313,10 @@ Specify that results should be sent to the browser using the output="yes" attrib Otherwise, subroutines will still have their effect, but the results will be tossed out. +Normally, the result from the subroutine is sent as-is, but you can set the interpolate="yes" attribute to let interpolate_fancy interpolate the results, as follows: + + <@plugin.subroutine arg1="a" arg2="bee" output="yes" interpolate="yes"/> + Content wrapped in the action call is sent as another argument to the subroutine: <@thePlugin.subroutine encoding="Latin1" output="yes"> @@ -343,6 +355,14 @@ sub foreshorten { return substr($content, 0, $attributes->{'length'}||$default_length); } +# This action includes the template specified in the 'name' attribute + +sub includetemplate { + my($self, $attributes, $content) = @_; + $name = $attributes->{'name'}; + return &$blosxom::template($blosxom::path_info, $name, $blosxom::flavour); +} + -- Calling these individually in a Blosxom flavour template looks something like: @@ -371,6 +391,11 @@ The following bit of text is only 20 characters in length and devoid of HTML: +The following includes the 'sidebar' template, while interpolating +the contents of that file: + +<@myplugin.include name="sidebar" output="yes" interpolate="yes"/> + =head1 INSTALLATION Drop the interpolate_fancy plug-in into your Blosxom plugins folder.