I worked with %INCLUDE and the possibility to use %START/STOPINCLUDE and %START/ENDSECTION. There I located one error in TWiki.pm.
Have a look to following
%STARTINCLUDE%
This is text inside of global INCLUDE
%STARTSECTION{ "part1" }
This is text inside of part 1
%ENDSECTION{ "part1" }
%STARTSECTION{ "part2" }
This is text inside of part 2
%ENDSECTION{ "part2" }
%STOPINCLUDE%
If you want to use this now with %INCLUDE following happens
%INCLUDE{ "MyTopic" } => you will see all 3 text elements
%INCLUDE{ "MyTopic" section="part1" } => you will see text element 1
%INCLUDE{ "MyTopic" section="part0" } => you will see the complete Topic, %<nop>START/STOPINCLUDE% elements are totally ignored!
I think the last one is wrong, it has to be following result: You should see nothing, because you want to import a non existing section.
I patched TWiki.pm as followed, I hope you will agree to this
--- TWiki.pm 2006-11-14 01:13:12.000000000 +0100
+++ TWiki.pm 2006-11-14 22:30:10.000000000 +0100
@@ -2757,7 +2757,7 @@
# handle sections
my( $ntext, $sections ) = _parseSections( $text );
- my $interesting = 0;
+ my $interesting = ( defined $section );
if( scalar( @$sections )) {
# Rebuild the text from the sections
$text = '';
--
ThomasFreudenberg - 15 Nov 2006
That makes sense. Please file a bug report, Bugs:WebHome.
--
PTh - 15 Nov 2006
Thanks Thomas, is now in SVN, 12001.
--
PTh
I feel a little uncomfortable with this, since it changes the current (though undocumented) behaviour.
In pre-12001, if I
%INCLUDE{...}%
a section which doesn't exist, then the whole topic gets included, regardless of whether it contains
%STARTINCLUDE%/%STOPINCLUDE%
markers.
I agree that this is a questionable behaviour, but I can see three alternative "improvements":
- If a non-existing section is included, behave as if the section parameter were absent. This means that, unlike pre-12001, the
%STARTINCLUDE%/%STOPINCLUDE%
markers should be respected
- If a non-existing section is included, don't include anything, as in 12001.
- If a non-existing section is included, return an error message, similar to that which you get if a non-existent topic is included.
I apologize for standing in the way - but if that behavioural change of revision 12001 is acceptable, I'd ask for three things:
- Urgent: TWiki:Codev.AddSectionParam
and %INCLUDE{...}%
must behave identically in case of non-existent sections. Currently, view
with a non-existing section
returns the whole topic, as did %INCLUDE{...}%
before r12001, and there is a test case in /test/unit/ViewParamSectionTests.pm
to confirm that.
- Low: An improvement of the documentation, which would apply to both VarINCLUDE and
view
in TWikiScripts (and could be done regardless of whether the change is approved or reverted).
- Enhancement: A test case differentiating between "before the fix" and "after the fix"
--
haj
On the alternative improvements, the current one is the most logical one imho.
Good point on documentation and test cases; more work needs to be done.
On
TWiki:Codev.AddSectionParam
spec change/clarification, let's track that in new bugs
Item3170.
--
PTh
PTh has augmented the documentation in
VarINCLUDE (12006), and I have added a testcase (12009). So we can mark it as "Waiting for Release" again.
Sorry for the interruption
--
haj
No, that is collaboration at its best! Thanks for adding a test case
--
PTh
4.1.0 released
KJL
I reopened the item again. If no section is defined at all, the inclusion of a non existing section will return the whole topic. That behaviour is the opposite of the documented behaviour.
--
OK
- 07 Mar 2007
I just got bitten by the bahviour Olli describes. Confirmed, and fixed on MAIN.
CC