Code Monkey home page Code Monkey logo

Comments (3)

g8d3 avatar g8d3 commented on May 21, 2024

I am trying something similar:

UI.registerHelper 'e', (a) ->
  a

template(name='test')
  = e 'asd'
  // I also tried
  = e asd

Any advice on how to pass arguments to helpers?

from meteor-jade.

dcsan avatar dcsan commented on May 21, 2024

@juanpastas your method names aer a bit cryptic.

i think you can just use handlebars {{ }}

template(name='test')
  {{e "blah" }}

or pass an object too.
what you can't do, afaik is to pass array indexes eg.

UI.registerHelper 'arrayItem', (ary, idx) ->
  return ary[idx]

template(name='test')
  {{arrayItem stuff 3}}
  {{arrayItem stuff 4}}
  {{arrayItem stuff 5}}

# there is some weird syntax to get at array content inside a template, maybe:
 {{stuff.0}}

# but it doesnt work for parameter passing
 {{someFunc stuff.0 }}

overall meteor jade seems to have a lot of holes from the normal jade spec but there's usually one way of doing things that works. you just have to poke around to find it!

from meteor-jade.

mquandalle avatar mquandalle commented on May 21, 2024

Due to the lack of inline javascript expression, it's not (yet) possible to use something like:

a(title=trans(this.text))

Instead you should use the following workaround:

a(title="{{trans text}}")

I'm closing in favor of #1

from meteor-jade.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.