Clinton Green
Clinton Green

Reputation: 9977

How to include an ember js helper function inside a handlebars expression

I want to include a helper myHelper inside a link-to expression like below but it seems you cannot have an expression directly inside another expression.

{{# link-to "someUrl" class="txt-dark-1 {{myHelper data}}"}} Some text {{/link-to}}

How could you include a helper function in this instance?

Upvotes: 0

Views: 104

Answers (1)

Ahmet Emre Kilinc
Ahmet Emre Kilinc

Reputation: 6885

If you want to use the value of your helper directly, you can call your helper via () instead of {} like this:

{{# link-to "someUrl" class="txt-dark-1" (myHelper data) }}
  Some text
{{/link-to}}

If you want to concat another string value to your class attribute, you can use it via concat helper like this:

{{# link-to "someUrl" class=(concat "txt-dark-1 " (myHelper data)) }}
  Some text
{{/link-to}}

Upvotes: 1

Related Questions