Pass parameters to template without overriding data context

前端 未结 2 1280
囚心锁ツ
囚心锁ツ 2020-12-05 20:26

I want to pass a new parameter to a template with keeping it\'s original data context.

  • original data context : {message:\"hello\"} {{> myTemplate withIc
2条回答
  •  攒了一身酷
    2020-12-05 21:06

    Building on David's second option to allow for multiple attributes:

    
    

    and then in javascript:

    Template.registerHelper('extendContext', function(data) {
      var result = _.clone(this);
      _.each(data.hash, function(value, key) {
        result[key] = value;
      })
      return result;
    })
    

提交回复
热议问题