Yes, the "else" is a good suggestion and I think it is doable.
FYI, I plan to implement this using a handler to represent the "if".
The handler will take a boolean expression and will conditionally invoke
its children based on the outcome. This implementation will be hidden
by the parser which will translate the proposed syntax automatically.
Work TBD:
* Make parser understand syntax.
* Provide flag to conditionally execute children (passed in HandlerContext)
* Change handler dispatching to respect this flag.
* Write "if" handler
This will also allow other handlers to set this flag via the
HandlerContext to conditionally render child handlers. However, I don't
have a syntax for child handlers yet. :) I think I'll just use curly
braces {}.
Ken
Anissa Lam wrote:
> Ken Paulsen wrote:
>>
>> I believe the '&' character does what you're asking and would look like:
>>
>> <!if $attribute(isTargetSupported) & $display(isStandAlone) &
>> $attribute(isWebModule)>
>> </if>
>>
>> NOTE: The "if" is also a component which has a "condition"
>> property... so it can be this way also:
>>
>> <if condition="...">
>> </if>
>>
>> However, looking at the code... I see I don't have handler-level
>> condition support. I forgot about this. :( I intentionally did not
>> implement it the same way as before b/c it was limiting and difficult
>> to span multiple handlers. I know how to implement what I planned,
>> and it won't take long... but I don't know how to represent it well
>> in the template file. Any suggestions?
>>
>> We're in a situation like this:
>>
>> <!beforeCreate
>> if (condition) {
>> handler1(foo="bar", x=>$attribute{y});
>> handler2();
>> }
>> />
>>
>> Should I do the if like that? Other ideas?
> I like this syntax much better than the previous framework. In the
> jato framework, if we have to call multiple handler, we have to keep
> repeating that "if" for every handler call.
> Is it possible to add an 'else' in your above proposal ?
> thanks
> Anissa
>
>>
>> Ken
>>
>> Jennifer Chou wrote:
>>> use && type operator in the if?
>>> <call name="getApplicationStatusSummary"
>>> if="$attribute(isTargetSupported)&&$display(isStandAlone)&&$attribute(isWebModule)">
>>>