Are built-in helpers (subexpressions) supported in Meteor?

I would use this: http://handlebarsjs.com/expressions.html#subexpressions

{{outer-helper (inner-helper 'abc') 'def'}}

But the meteorite gives me an error ... is there some solution or workaround for using nested assistants?

thank!

+4
source share
3 answers

Now it is possible with version 1.2

<p>
    Together we have
    {{pluralize (add myWidgetCount yourWidgetCount), "widget"}}
</p>

https://quip.com/RXFlAk9Rc2xI#dbfACAYxaJX

+7
source

Nested helper: if there is a positional argument followed by others (positional or key arguments), the first argument is called for the rest using the convention of invoking a regular auxiliary argument.

Passing helperB to helperA

{{helperA helperB}}

'helperB x' helperA

{{helperA helperB x}}

'helperB x = false' helperA

{{helperA helperB x=false}}

https://github.com/meteor/meteor/blob/devel/packages/spacebars/README.md#inclusion-and-block-arguments

+2

, : http://docs.meteor.com/#ui_registerhelper, http://docs.meteor.com/#template_helpers .

, spacebars, , , : < 2 >

:

// template
<template name="_maybeDiv_wrapInDiv">
  <div>
    {{> UI.contentBlock}}
  </div>
</template>

<template name="_maybeDiv_noop">
  {{> UI.contentBlock}}
</template>

// client code
UI.registerHelper('maybeDiv', function () {
  var isBlock = this.valueOf();

  if (isBlock)
    return Template._maybeDiv_wrapInDiv;
  else
    return Template._maybeDiv_noop;
});

{{#maybeDiv true}}
  contents
{{/maybeDiv}}
0

Source: https://habr.com/ru/post/1540685/


All Articles