spmjs / spm2

源码已合并到
https://github.com/spmjs/spm/tree/2.x
Other
126 stars 26 forks source link

require tpl模板文件出错 #93

Closed ghost closed 11 years ago

ghost commented 11 years ago

现在我的模块中有require tpl代码 打包后有如下两部分代码 require: var projectBodyTemplate = require("my/0.0.1/profile/templates/profile.tpl");

tpl: define("my/0.0.1/profile/templates/profile.tpl", [], '----------------------模板内容-------------------‘);

但是projectBodyTemplate 最后得到的值是null。

是否有将tpl直接转换为文本的方式。

ghost commented 11 years ago

简单的文件没问题,但我的工程中有问题,现在是否还有将tpl直接转换为文本的方式。

popomore commented 11 years ago

有的,提供下有问题的代码

— Sent from Mailbox for iPhone

On Wed, Oct 9, 2013 at 5:55 PM, f0x1l notifications@github.com wrote:

简单的文件没问题,但我的工程中有问题,现在是否还有将tpl直接转换为文本的方式。

Reply to this email directly or view it on GitHub: https://github.com/spmjs/spm2/issues/93#issuecomment-25959108

ghost commented 11 years ago

应该是解析tpl别名的问题。公司的代码,不好提供。简单的程序复现不了,我再研究研究。 spm build时将tpl直接转换为文本的方式 能够提供个链接吗,谢谢。

popomore commented 11 years ago

要源码的链接?

ghost commented 11 years ago

文档的链接。 build完成后直接生成 var projectBodyTemplate = "模板内容"

ghost commented 11 years ago

发现问题了,使用seajs1.3.1版本, seajs.config({ preload: ['seajs/plugin-text'] }); 原本要用这个插件,但是现在这个插件加上有问题。

ghost commented 11 years ago

这个插件应该是针对外部的tpl文件进行处理,但是现在spm build将tpl文件和js打包到了一个文件中。所以造成无法获取正常的结果。

popomore commented 11 years ago

最后应该生成这样的

define('a.js', [], function(require){
  require('./a.tpl');
});
define('a.tpl', [], function(require){
  return '...'
});