Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize sub template include logic in compiled code #2

Closed
yiminghe opened this issue Aug 22, 2014 · 4 comments
Closed

optimize sub template include logic in compiled code #2

yiminghe opened this issue Aug 22, 2014 · 4 comments
Milestone

Comments

@yiminghe
Copy link
Member

current compiled code

a.xtpl

{{include('./b')}}{{x}}

a.js

function(){
  params2.push('./b-xtpl');
  config1.params = params2;
  if(moduleWrap){
     require('./b-xtpl');
  }
}

optimized compiled code

a.xtpl

{{include('./b')}}{{x}}

a.js

function(){
 var submodule;
 if(moduleWrap){
     submodule = require('./b-xtpl');
 }
 params2.push(submodule  && submodule.TPL_NAME||'./b-xtpl');
 config1.params = params2;
}
@maxbbn
Copy link

maxbbn commented Aug 22, 2014

submodule.name 在什么情况下会不存在?

@yiminghe
Copy link
Member Author

@maxbbn 是 TPL_NAME 是 https://github.com/kissyteam/gulp-xtemplate 放的

@maxbbn
Copy link

maxbbn commented Aug 22, 2014

1.4.1 构建的代码里面没有这个变量, 是 之后版本里面加的吗? 哪里能看到编译后的代码

@yiminghe
Copy link
Member Author

嗯 1.4.x 没.... 所以 new 的时候如果依赖子模块 要指定 name ...

new X(fn,{name:'xx/yy'});

目前主干代码例子:https://github.com/kissyteam/kissy/blob/master/build/combobox-debug.js

@yiminghe yiminghe added this to the 1.2.4 milestone Aug 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants