• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item3620: %IF% does not resolve BASETOPIC

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Normal No Action Required   n/a  

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

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:

  1. See %INCLUDE in IncludeBaseTopic
  2. Read BaseTopic. Expand TOPIC and a number of other variables
  3. Include the expanded text in the text of IncludeBaseTopic
  4. 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

ItemTemplate
Summary %IF% does not resolve BASETOPIC
ReportedBy TWiki:Main.ArthurClemens
Codebase

SVN Range TWiki-4.1.1, Fri, 09 Feb 2007, build 12817
AppliesTo Engine
Component

Priority Normal
CurrentState No Action Required
WaitingFor

Checkins

TargetRelease n/a
ReleasedIn

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2007-04-23 - CrawfordCurrie
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback