I try to avoid the IF task. Unless I have a very small block of things
to put into it. I tend to use the IF and UNLESS attributes a lot more...
and break up what you want to happen on TRUE vs FALSE in separate
targets. Then you can CALL target="dothis" if="${thisistrue}"
BOb
________________________________
From: Parrish, Ken [mailto:kparr...@gomez.com]
Sent: Tuesday, April 28, 2009 3:05 PM
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] If - else statement ...
A while back I inquired about an 'else' or 'elseif' clause in an <if>
task. Presently, I use the <choose> task instead-e.g.:
<choose>
<when test="${}" >
</when>
<otherwise>
</otherwise>
</choose>
Just wonder if anyone has yet created a custom task with a more concise
syntax (e.g. not doubly nested)?
Optional 'else' clauses always create problems with language
parsers-they are fundamentally a deviation for well-formed LALR(1)
language parsers. I'm not even sure what would be a good way to
represent IF - ELSE - ENDIF constructs in Nant. Maybe as three separate
tasks:
<if test="${}" />
<else test = "${}" />
<endif/>
Or as two tasks:
<if test="${}" >
</if>
<else test = "${}" >
</else>
In either case, there's an issue that either the nesting/scoping of
elements is not reflective of the control construct, or that the Nant
processor would have to keep track of state transitions outside of a
single control structure (what happens if you encounter an <else> that
is syntactically acceptable, but not preceded by an <if> task ???
Any thoughts, ideas on this topic.
Ken Parrish
Gomez, Inc.
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users