peerlibrary / meteor-blaze-components

Reusable components for Blaze
http://components.meteorapp.com/
BSD 3-Clause "New" or "Revised" License
354 stars 26 forks source link

String interpolation in component arguments #67

Closed pixelass closed 9 years ago

pixelass commented 9 years ago

Is it possible to do something like this?

{{>myComponnent option="foo:{{#if foo}}yes{{/if}}{{#else}}no{{/else}}"}}

or

{{>myComponnent option="foo:{{foo}}"}}

I am writing my components in Jade so there I can at least use this

+myComponnent(option="foo:#{foo}")

but obviously I don't want them to be tied to any syntax or transpiler logic

I didn't find any documentation so maybe you can help me find an answer to this.

mitar commented 9 years ago

No. This is not possible in Blaze. It is also probably too much logic for Handlebars pure separation of concerns.

You can do:

{{>myComponnent option=option}}
class myComponent extends BlazeComponent
  option: ->
    "foo:#{if @data().foo then 'yes' else 'no'}"
pixelass commented 9 years ago

Yea I was guessing that.. I was just wondering why I could do some string interpolation in Jade but not in spacebars since the Jade implementation of meteor only uses Jades lexer and syntax..

I will just have the people build this logic into their templates.

Thx for the answer.

Issue can be closed.