Hash Expression
[PROPERTY_NAME=EXPRESSION ]+
A sequence of one or more property names and their values as another expression like:
prop1=1 prop2=key prop3=callExpression()
In a Call Expression, Hash
expressions
create an object argument with the specified PROPERTY_NAME
properties
and EXPRESSION
values.
The following template:
{{ method( age=5 first=person.firstName last=person.getLastName() ) }}
Might call method
with:
{age: 5, first: "Justin", last: "Meyer"}
In a Helper Expression, Hash
expressions
add to the helperOptions’s hash
object with the specified PROPERTY_NAME
properties
and EXPRESSION
values.
The following template:
{{ method age=5 first=person.firstName last=person.getLastName() }}
Might call method
with:
{
hash: {age: 5, first: compute("Justin"), last: compute("Meyer")}
}
Parameters
- PROPERTY_NAME
{String}
:The property name on the call expression argument object or helperOptions’s
hash
object. - EXPRESSION
{Literal Expression|KeyLookup Expression|Call Expression}
:An expression that provides a value for the property name.
Use
A hash expression specifies a property value on a object argument in a call expression and property value on the the hash object in a helper expression’s helperOptions argument.
For example, in a call expression:
<!-- Template -->
{{methodA(prop=key)}}
{{methodB(propX=key propY='literal', propZ=5)}}
/* Data */
{
methodA: function(arg){},
methodB: function(arg1, arg2){},
key: compute("value")
}
methodA
will be called with{prop: "value"}
asarg
.methodB
will be called with{propX: "value", propY: 'literal'}
asarg1
and{propZ: 5}
asarg2
In a helper expression:
<!-- Template -->
{{methodA prop=key}}
{{methodB(propX=key propY='literal' propZ=5)}}
/* Data */
{
methodA: function(options){},
methodB: function(options){},
key: compute("value")
}
methodA
will be called with{prop: compute("value")}
asoptions.hash
.methodB
will be called with{propX: "value", propY: 'literal', propZ: 5}
asoptions.hash
.