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

require tpl模板文件出错 #93

Closed
ghost opened this issue Oct 9, 2013 · 8 comments
Closed

require tpl模板文件出错 #93

ghost opened this issue Oct 9, 2013 · 8 comments

Comments

@ghost
Copy link

ghost commented Oct 9, 2013

现在我的模块中有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
Copy link
Author

ghost commented Oct 9, 2013

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

@popomore
Copy link
Member

popomore commented Oct 9, 2013

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


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:
#93 (comment)

@ghost
Copy link
Author

ghost commented Oct 9, 2013

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

@popomore
Copy link
Member

popomore commented Oct 9, 2013

要源码的链接?

@ghost
Copy link
Author

ghost commented Oct 10, 2013

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

@ghost
Copy link
Author

ghost commented Oct 10, 2013

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

@ghost ghost closed this as completed Oct 10, 2013
@ghost
Copy link
Author

ghost commented Oct 10, 2013

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

@popomore
Copy link
Member

最后应该生成这样的

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

This issue was closed.
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

1 participant