Sha256: 86f5be5eab0ca99eca258bd02f3867c6df6cd7905a1d1e94ab1e497d23ab0142

Contents?: true

Size: 713 Bytes

Versions: 5

Compression:

Stored size: 713 Bytes

Contents

import {appendContextPath, blockParams, createFrame, isEmpty, isFunction} from '../utils';

export default function(instance) {
  instance.registerHelper('with', function(context, options) {
    if (isFunction(context)) { context = context.call(this); }

    let fn = options.fn;

    if (!isEmpty(context)) {
      let data = options.data;
      if (options.data && options.ids) {
        data = createFrame(options.data);
        data.contextPath = appendContextPath(options.data.contextPath, options.ids[0]);
      }

      return fn(context, {
        data: data,
        blockParams: blockParams([context], [data && data.contextPath])
      });
    } else {
      return options.inverse(this);
    }
  });
}

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
locomotivecms-4.0.0.alpha1 app/javascript/node_modules/handlebars/lib/handlebars/helpers/with.js
locomotivecms-3.4.0 app/javascript/node_modules/handlebars/lib/handlebars/helpers/with.js
lanes-0.8.0 node_modules/handlebars/lib/handlebars/helpers/with.js
eslint_node_modules-1.6.0.1 vendor/node_modules/eslint/node_modules/handlebars/lib/handlebars/helpers/with.js
eslint_node_modules-1.6.0 vendor/node_modules/eslint/node_modules/handlebars/lib/handlebars/helpers/with.js