Feature Proposal: Add default value to STARTSECTION

Motivation

In trunk you can now set a default value for a TMPL:P, the default is set in the TMPL:DEF:
%TMPL:DEF{"x" y="1"}% x%y%z %TMPL:END% 

(see http://trunk.foswiki.org/System/SkinTemplates#Block_definition_parameters)

This principle does not exist yet with STARTSECTION / INCLUDE.

We should make sure that TMPL:P, Set and sections work the same way.

Problem

Let's say I want to have a section where a value should have a default size of 10.

Currently I can only say: INCLUDE{"topic" size="10"}, and in STARTSECTION handle this with %size%. But this breaks if size is not passed by INCLUDE.

To get around this, you need this construction inside the section:
%STARTSECTION{"select"}%
size='%IF{
    "defined size AND $size"
    then="%size%"
    else="10"
}%'
%ENDSECTION{"select"}%

It is too complex and error prone.

Description and Documentation

Desired syntax:
%STARTSECTION{"select" size="10"}%
size='%size%'
%ENDSECTION{"select"}%

where the default value is used as long as param size is not passed.

%WHATDOESITAFFECT%
edit

Implementation

-- Contributors: ArthurClemens - 24 May 2012

Discussion

I agree - its all part of what 1.2.0 is about for me - coalessing the functionalities of paramaterised variables, TMPL and sectional includes, so that in a future release we can see what can be merged.

-- SvenDowideit - 24 May 2012

For what it's worth, CrawfordCurrie 's parameterized variables work means (I think) that this should work also (less elegant, but not quite as less-elegant as the IF solution):
%STARTSECTION{"select"}%
size='%size{default="10"}%'
%ENDSECTION{"select"}%

-- PaulHarvey - 25 Jun 2012 - 05:33

Michael came across a problem that I'm hoping we can make a unit test for, but other than that - this feature is either implemented, or if we find a mis-compatibility, will need re-thinking.

At its root, we are changing what preferences are set when INCLUDE-chaining.

-- SvenDowideit - 26 Jun 2012

Sven (or Michael) - can you elaborate on what the problem is?

-- KipLubliner - 28 Jun 2012

Kip - see Tasks.Item11969

-- SvenDowideit - 30 Jun 2012
Topic revision: r9 - 05 Jul 2015, GeorgeClark
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