meteor-jade
meteor-jade copied to clipboard
passing arguments to helper syntax
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/
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.
:+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))
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.