Skip to content

runtime 设计 #2

Description

@popomore

与 templatable 区别

  • runtime 直接给 handlebars 用的,template 只支持函数
  • 模板以 .handlebars 结尾,spm 会编译成 cmd 模块,开发环境使用 plugin-handlebars.js
  • 用户使用的时候需要自己编译模板,实例化的时候无法传入字符串。所以比较适合像 calendar 这种没啥修改模板的组件
  • 去掉 renderPartial
  • 增加 compile 方法,重新全局渲染
  • 不再使用 this.model 和 this.template,取而代之使用属性

review 下现有代码

https://github.com/aralejs/templatable/blob/master/src/runtime.js

compile 也可以支持简单的 selector

  • 用 jquery 实现 this.element.html($(this._compile()).find(selector).html());
  • 用正则匹配,不过只能支持常使用的选择器

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions