dev@cloudburo

Meteor Small Hints #2: Calling local methods in a Template

At the end it is straightforward but took me some time to figure out, how to call local methods in a Meteor template file.

Just add the local methods without any scope at the beginning.


  isStep1OK = () -> 
    Meteor.user().emails[0].verified 


  getStepStatus1 = ()-> 
    if (isStep1OK()) 
     "glyphicon glyphicon-ok-sign icon-success" 
    else 
      "glyphicon glyphicon-minus-sign icon-failure" 


  getStepStatus2 = () -> 
    "glyphicon glyphicon-minus-sign icon-failure" 


  getStepStatus3 = () -> 
    "glyphicon glyphicon-minus-sign icon-failure" 


  Template.curationLanding.helpers 


    getStepStatus: (step) -> 
      switch step 
        when 1 then getStepStatus1() 
        when 2 then getStepStatus2() 
        when 3 then getStepStatus3() 


    getStepStatus1Text: () -> 
      if (isStep1OK()) 
        TAPi18n.__ "landingStep1OK" 
      else 
        TAPi18n.__ "landingStep1NOK" 

comments powered by Disqus