Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

templatable 支持 handlebars runtime #33

Closed
lepture opened this Issue Mar 22, 2013 · 3 comments

Comments

Projects
None yet
2 participants
Member

lepture commented Mar 22, 2013

接下来我们将使用 handlebars runtime,widget 的 templatable 可以删掉了。

下面介绍一下 runtime 的工作原理:

我们有一个模板:

{{ _ word }}

编译后得到一个 cmd 模块,这个模块返回一个 function,记为 fn。然后我们调用这个 fn:

fn({word: 'hello'}, {
  helpers: {
    '_': function(key) {
        return '你好'
    }
  }
})

就 ok 了。

This was referenced Mar 22, 2013

Owner

popomore commented Apr 2, 2013

  1. templatable 还是保留
  2. template 可以支持为 fn 和 string,在 widget 内部判断
  3. handlebars 模板,会生成一个编译好的 cmd 文件,自带 runtime。
  4. 去除 renderPartial,写法再补充
Owner

popomore commented Apr 2, 2013

@lifesinger 考虑说换引擎 Hogan.js,不过这是个长远考虑的事。

This was referenced Apr 2, 2013

Owner

popomore commented May 15, 2013

widget 支持了 handlebars 的 runtime 版本,暂时不去除 renderPartial,感觉没有考虑清楚。如果不需要这个功能,可以像 calendar 一样自己实现一个简单的。

但准备把 templatable 移除 widget 单独建库,并保留现有功能。以后修改只需要改 templatable 的依赖,不需要动底层库。

@popomore popomore closed this May 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment