liudong
2023-05-29 340f156319b863525e50e900c58e59b86ecb3d5e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { extend } from '../utils';
 
export default function(instance) {
  instance.registerDecorator('inline', function(fn, props, container, options) {
    let ret = fn;
    if (!props.partials) {
      props.partials = {};
      ret = function(context, options) {
        // Create a new partials stack frame prior to exec.
        let original = container.partials;
        container.partials = extend({}, original, props.partials);
        let ret = fn(context, options);
        container.partials = original;
        return ret;
      };
    }
 
    props.partials[options.args[0]] = options.fn;
 
    return ret;
  });
}