Aria Templates Forums
[OPEN] Behavoiur of the "Default Available Modifiers" default - Printable Version

+- Aria Templates Forums (
+-- Forum: Public forums (/forumdisplay.php?fid=3)
+--- Forum: General framework discussions (/forumdisplay.php?fid=4)
+--- Thread: [OPEN] Behavoiur of the "Default Available Modifiers" default (/showthread.php?tid=110)

[OPEN] Behavoiur of the "Default Available Modifiers" default - donk - 8 November 2013 10:53


I created a template and used the default modifier to specify a default value:


But when data.amountInfo is null I get an error because of a JavaScript TypeError and nothing will be printed instead of the default value.

Your documentation states:

Quote:This modifier returns the default value if the entry value is equal to null (this is a non-strict equal, so "" is considered as null).

So I guess the behavior is correct regarding your documentation. But I think it would be more practical for everyday use if you extend the check , so that the default value will always be printed if the expression evaluates to null or throws an TypeError.

Otherwise I would have to use this form instead, which is more code for the same default behavior.

{if data.amountInfo}

And it gets worse if the nesting is even deeper

{if data.amountInfo &&}


{if data.amountInfo}

So either extending the default modifier or another modifier for this situation would be nice.

RE: Behavoiur of the "Default Available Modifiers" default - jakub-g - 11 November 2013 14:27

I agree it would indeed be useful to have this feature from the TPL writer perspective to save some code - even separated from the modifiers.

Side note: CoffeeScript supports that feature, but using a special
syntax (scroll to "The Existential Operator").
It was considered to be added to C# as
(the other way around) but hasn't made it yet:

Following the CoffeeScript, basically, the input string
could be transformed on our side to the following JS:
(data && data.amountInfo && ? : null
and then processed further.

But let's consider the following

This would have to be translated recursively into sth like
data ? ( ? ( : null ) : null

It's useful from the user perspective, however this would further complicate our parser and the Eclipse editor. What's the team opinion on this?

RE: Behavoiur of the "Default Available Modifiers" default - susanta.behera - 12 November 2013 12:17

This will be a good feature addition.
+1 for this