• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7700 for generic doc work for TWiki-6.0.2. Use View topic Item7703 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.

Item7463: Conditional IF not working as documented; prints literal text

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Extension IF 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 have the following code in my TWiki/WebTopBar
   * %IF{ "$action~'*Hide*'" then="$percentINCLUDE{\"Help/HideWebLeftBar\"}$percent" }%
<form name="hideshow" action="%SCRIPTURLPATH{"view"}%/%INCLUDINGWEB%/%INCLUDINGTOPIC%" method="get">
<input type="hidden" name="hideleftbar" value="1" />
<input type="image" src="%PUBURL%/%USERSWEB%/DocumentGraphics/%IF{ "$action~'*Hide*'" then="showleftbar.png" else="hideleftbar.png" }%" title="%IF{ "$action~'*Hide*'" then="Show Left Bar" else="Hide Left Bar" }%" name="action" value="%IF{ "$action~'*Hide*'" then="Show Left Bar" else="Hide Left Bar" }%" />
</form>

The code runs when I click on the image. However, the conditional INCLUDE does not work as expected/documented.

ref: IfStatements, Examples,

11. Conditional include
%IF{"'%USERNAME%' ingroup 'ExecutiveGroup'" then="$percntINCLUDE{ExecutiveReport}$percnt"}% 

When the first IF fires (i.e. when $action~'*Hide*') instead of including Help/HideWebLeftBar, it prints the string

$percentINCLUDE{\"Help/HideWebLeftBar\"}$percent

see: http://www.cfcl.com/twiki6/bin/view/System/WebTopBar for this code i_in situ_

-- TWiki:Main/VickiBrown - 2014-03-18

It prints $percentINCLUDE because the syntax is $percnt, not $percent.

-- TWiki:Main.PeterThoeny - 2014-03-18

I'm so embarrassed!

(Ken Thompson was once asked what he would do differently if he were redesigning the UNIX system. His reply: "I'd spell creat with an e.")

-- TWiki:Main.VickiBrown - 2014-03-26

ItemTemplate
Summary Conditional IF not working as documented; prints literal text
ReportedBy TWiki:Main.VickiBrown
Codebase 6.0.0
SVN Range TWiki-6.0.1-trunk, Sun, 16 Mar 2014, build 27153
AppliesTo Extension
Component IF
Priority Normal
CurrentState No Action Required
WaitingFor

Checkins

TargetRelease n/a
ReleasedIn

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