meteor-jade icon indicating copy to clipboard operation
meteor-jade copied to clipboard

passing arguments to helper syntax

Open avalanche1 opened this issue 9 years ago • 3 comments

Hey, @mquandalle! I have this particular markup and had to resort to native spacebars syntax for passing arguments to helper inside {{parentRegion _id}}.

.menu
  +each city
    .item(data-id='#{_id}') #{name}<span style="color:lightgrey;"> {{parentRegion _id}}</span>
tpl.helpers
  city:-> Geo.find({type:'city'})
  parentRegion: (id)->
    id= new RegExp('^'+id.slice(0,7))
    Geo.findOne({_id:id,type:'region'}).name

I tried using +parentRegion(_id) as in https://github.com/mquandalle/meteor-jade/blob/master/README.md#components but this returned me plain text '+parentRegion(_id)'. So is there a way to do this natively in Jade?

ps more details https://forums.meteor.com/t/solved-call-helper-from-another-helpers-context-or-smth-like-that/

avalanche1 avatar Jun 02 '15 14:06 avalanche1

I am having this same issue.

I am trying to do:

input(type='text', name='birthday', placeholder='birthday', value='#{dateFormatter currentUser.profile.birthday}')

Where date Formatter is a global helper. For testing I defined it as so:

UI.registerHelper 'dateFormatter', (date) ->
  return date

So basically jade should output whatever parameter I input. But in the page I also see ''#{dateFormatter currentUser.profile.birthday}' output as a string.

sferoze avatar Jun 02 '15 21:06 sferoze

:+1: i would even like to be able to use the parenthesis syntax if possible. Will check it soon if I have time, this one is annoying me too much : input(value=(myHelper myParam))

mcoenca avatar Jul 03 '15 13:07 mcoenca

I've modified a fork of this package to support passing arguments to helpers, together with a few other useful features. The fork has been released as dalgard:jade.

I will keep the new package in sync with the original, should there be any updates, and generally continue maintenance until, hopefully, the two packages can be merged.

dalgard avatar Oct 14 '15 11:10 dalgard