I would like to test if a topic is included. If the topic is included, TOPIC is not BASETOPIC. If it is not included, TOPIC is BASETOPIC. But
IF
does not help me with this evalutation.
Test:
%IF{"'$ TOPIC'='$ TOPIC'" then="TOPIC" }%
Results in: TOPIC
%IF{"'$ TOPIC'='$ BASETOPIC'" then="BASETOPIC" }%
Results in:
--
TWiki:Main/ArthurClemens
- 12 Feb 2007
Probably because either TOPIC or BASETOPIC is defined as a function and not a TWiki variable.
--
TWiki:Main.CrawfordCurrie
- 13 Feb 2007
%IF{"$ TOPIC='%TOPIC%'" then="TOPIC" else = "bah"}%
Results in: TOPIC
%IF{"$ TOPIC=$ BASETOPIC" then="BASETOPIC" else="bah"}%
Results in: BASETOPIC
Looks OK to me. Arthur, you used single quotes, which means '$ BASETOPIC' is a string.
No action.
CC
Still the result is not what it should be. See
IncludesBaseTopicTest
AC
No, that's fine. Here's why:
In an included topic, only a subset of TWiki variables is expanded before the topic text is included in the parent topic. TOPIC is one of these. IF is
not. So, when
BaseTopic is included, the process goes like this:
- See %INCLUDE in IncludeBaseTopic
- Read BaseTopic. Expand TOPIC and a number of other variables
- Include the expanded text in the text of IncludeBaseTopic
- Expand other TWiki variables, including IF
If you want the behaviour you imply by your test, then you have to use a syntax that is expanded in the included text. For example:
%IF{"'%TOPIC%'='%BASETOPIC%'" then="true" else="false"}%
--
CrawfordCurrie - 23 Apr 2007