From: Matthijs Kooijman Date: Fri, 19 Dec 2008 11:46:34 +0000 (+0100) Subject: Add a "interpolate" attribute for all actions. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fblosxom-plugins.git;a=commitdiff_plain;h=29211a57ae6826974c034d8c347af4e13aa56467 Add a "interpolate" attribute for all actions. Setting the "interpolate" attribute to "yes" on an action interpolates the result of the action again. --- 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.