Skip to content

Instantly share code, notes, and snippets.

@ef4
Last active October 31, 2018 16:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ef4/bb6b53d7b931591455e2c12d11d62545 to your computer and use it in GitHub Desktop.
Save ef4/bb6b53d7b931591455e2c12d11d62545 to your computer and use it in GitHub Desktop.

How to use positionalParams in Angle Bracket invocation

A component with positionalParams always also has named versions of its parameters. For example, the liquid-if component from liquid-fire has this in its Javascript file:

positionalParams: ['predicate']

So these are equivalent:

{{#liquid-if isActive}}
{{/liquid-if}}

<LiquidIf @predicate={{isActive}} >
</LiquidIf>

There is a second way to use positionalParams, which is to gather a variable number of them into an array. That is how link-to works:

// notice that the right-hand value here is a single 
// name, not an array like in the previous example
positionalParams: 'params'

You can use the same trick here, but unfortunately the value you pass needs to be an array, so you may want something like ember-array-helper:

{{link-to "posts" 1}}
<LinkTo @params={{array "posts" 1}} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment