Giter Site home page Giter Site logo

templatable's People

Contributors

afc163 avatar jaredleechn avatar lizzie avatar popomore avatar sehuo avatar sorrycc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

templatable's Issues

runtime 设计

与 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());
  • 用正则匹配,不过只能支持常使用的选择器

关于attr

attr中的template属性,我看到dialog之类的组件,都是可以在组件内部赋值的,但是我写的组件,只能 new XXX({
template:""
});
来制作模板,如果我没有通过参数方式制定模板,内部的attr template 并没有生效,会默认生成一个 空div,很奇怪,我少了哪一步吗?

从 widget 迁移出 templatable

这个库有两个文件 templatable.js 和 runtime.js。

templatable 保持原来的功能;runtime 是简单版的,只支持 handlebars runtime 并且去除了 renderPartial。

迁移的目的是 templatable 的功能本身就相对独立,迁移出来可以方便修改而不会影响底层 widget 组件。

以后可以考虑增强 model 的功能。

aralejs/widget#43

如何返回html代码

{{表达式}}返回的是SafeString,但有时候,我希望返回的是html代码,而不是转义之后的文本,可以通过配置实现吗,或者只能使用helper?

如何实现简单语句

{{#if gender == 'male' }}
// dosth...
{{/if}}

如何实现上面操作,必须用helper吗?
widget可以使用指定模板吗,如ejs?

model更新时候的页面刷新

我想问一下,model的内容是通过ajax动态获取和改变的,每次改变的时候我是需要重新new 一下自己扩展的TemplateWidget(继承Widget)再render吗?这样对性能会不会有影响?

templateObject 为 undefined 时, 会重复渲染 this.element 同样的模板内容

目前发现这几个组件 autocomplete/select/intro 中, 由于 template 从 .tpl 改成了 .handlebars, this.get("template") 由原来的 string 变成了 Function, 导致在 parseElementFromTemplate (https://github.com/aralejs/templatable/blob/master/src/templatable.js#L18) 时, 使得 this.templateObject 为 null.

再当这几个组件使用 this.renderPartial('[data-role=content]'); 方法时, 使得 https://github.com/aralejs/templatable/blob/master/src/templatable.js#L80 这里的 if 分支 从 执行 true 分支换成了 false 分支, 导致 render 之后, 会出现两个父 div, 即类似于:

<div class="ui-autocomplete" data-widget-cid="widget-0" style="z-index: 99; display: none;">
<div class="ui-autocomplete">
    <ul class="ui-autocomplete-ctn" data-role="items">

            <li data-role="item" class="ui-autocomplete-item" data-value="[email protected]">[email protected]</li>

            <li data-role="item" class="ui-autocomplete-item" data-value="[email protected]">[email protected]</li>

            <li data-role="item" class="ui-autocomplete-item" data-value="[email protected]">[email protected]</li>

    </ul>
</div>
</div>

解决方法的话, 是否得让 convertTemplateToObject 中, 当 template 为 Fn 时, 不返回 null, 但如果是字符串对象的话, 那当前 model 为空, 怎么编译生成字符串呢...

另外, 是否得让容器模板 和 内容模板分开?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.