3

How can we call a function with parameters in emblem's conditional statement. Like I have a function:

priorExist: (prior) ->
      @get("priors").findBy("condition", prior)

But I get an error when I call it in emblem like this

if priorExist(name)

Is there any way to call above function in emblem?

Adnan Ali
  • 2,890
  • 5
  • 29
  • 50

1 Answers1

3

Above Functionality can be achieved by using Ember Components Like this

Component if-existing-prior-component.coffee/js

App.IfExistingPriorComponent = Ember.Component.extend(existingPrior: (->
  @get("param2").findBy("condition", @get("param1"))
).property("param1"))

if-existing-prior Template

if existingPrior
  = yield

Then we can use above component for comparisons in our emblem like this:

if-existing-prior param1=name param2=priors

Where priors = @get("priors")

Adnan Ali
  • 2,890
  • 5
  • 29
  • 50