Item2042: TablePlugin: Add a new initialiseWhenRender() API

pencil
Priority: Enhancement
Current State: Closed
Released In: 1.0.7
Target Release: patch
Applies To: Extension
Component:
Branches:
Reported By: KennethLavrsen
Waiting For: Main.KennethLavrsen
Last Change By: KennethLavrsen
I am adding a TablePlugin only API call called initialiseWhenRender()

Other plugins can reinitialise the plugin which will reset all table counters etc next time the preRenderingHandler is run.

The preRenderingHandler is called again when a plugin uses the Foswiki::Func::renderText method.

A plugin like CompareRevisionsAddOn uses initialiseWhenRender between the rendering of two revisions of the same topic to avoid table numbers to continue counting up when rendering the topic the second time.

Example of use in a plugin taking care to check for TablePlugin being installed and being of a version that contains this method.

Otherwise using a "mother of hacks" to get to the same result.

if ( defined &Foswiki::Plugins::TablePlugin::initPlugin ) { if ( defined &Foswiki::Plugins::TablePlugin::initialiseWhenRender ) { Foswiki::Plugins::TablePlugin::initialiseWhenRender(); } else { # If TablePlugin does not have the reinitialise API # we use try a shameless hack instead if ( defined $Foswiki::Plugins::TablePlugin::initialised ) { $Foswiki::Plugins::TablePlugin::initialised = 0; } } }

Adding this API is the most clean way to fix Item1911

Is does not change any existing feature in TablePlugin. It is fully compatible.

I will first check in the code and later add a unit test once I know the community has had their say on improvements and choice of name.

Note that the call does not reset the plugin which is why I did not call it reset. The initialisation does not happen unless the plugin preRenderingHandler is called for example by using the Foswiki::Func::renderText API.

This makes the API call unique to TablePlugin and there is nothing in the way of later adding a generic reset method to plugins including this. This is not the purpose of this.

This API call has the purpose of being used by plugins that need to render the same topic multiple times (like different versions of the same topic) and present the rendered results in the same output like CompareRevisionsAddOn does.

-- KennethLavrsen - 12 Sep 2009

I will postpone the unit test till the trunk does not end a unit test run with 1829 of 1863 test cases passed

It is impossible to develop anything safely when so many tests are left broken

-- KennethLavrsen - 12 Sep 2009

Unit tests added. Closing (released in 1.0.7)

-- KennethLavrsen - 29 Sep 2009

ItemTemplate edit

Summary TablePlugin: Add a new initialiseWhenRender() API
ReportedBy KennethLavrsen
Codebase
SVN Range Foswiki-1.0.0, Thu, 08 Jan 2009, build 1878
AppliesTo Extension
Component
Priority Enhancement
CurrentState Closed
WaitingFor KennethLavrsen
Checkins distro:4f07595132e1 distro:ff661e29d9c8 distro:be61856bb92d distro:1404d7f96f84
TargetRelease patch
ReleasedIn 1.0.7
Topic revision: r5 - 29 Sep 2009, KennethLavrsen
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy