makeBoundHelper alternative in Ember 2.0

痞子三分冷 提交于 2019-12-01 18:51:19

You would use the Ember.Helper.helper syntax:

import Ember from 'ember';

const { Helper: { helper }, run: { schedule }, $ } = Ember;

export function helperName(params, hash) {
  let parsedHtml = $('<div />').html(params[0])

    // Push the ads after the divs have been rendered
   schedule('afterRender', function() {
      googletag.cmd.push(function() { googletag.display('div-gpt-ad-111111111-0'); });
    }) 
  }

  return parsedHtml.html();
}

export default helper(helperName);

Params is an array of all the values that you pass to the helper in your template such as {{my-helper val1 val2 val3}} params[0] is val1 and so on, the hash is an object containing all the properties you set on the helper {{my-helper val1 val2 property1=myPropValue}} and you would access it via hash.property1.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!