Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / handlebars / lib / handlebars / helpers / with.js
1 import {appendContextPath, blockParams, createFrame, isEmpty, isFunction} from '../utils';
2
3 export default function(instance) {
4   instance.registerHelper('with', function(context, options) {
5     if (isFunction(context)) { context = context.call(this); }
6
7     let fn = options.fn;
8
9     if (!isEmpty(context)) {
10       let data = options.data;
11       if (options.data && options.ids) {
12         data = createFrame(options.data);
13         data.contextPath = appendContextPath(options.data.contextPath, options.ids[0]);
14       }
15
16       return fn(context, {
17         data: data,
18         blockParams: blockParams([context], [data && data.contextPath])
19       });
20     } else {
21       return options.inverse(this);
22     }
23   });
24 }