1 |
|
2 |
|
3 |
|
4 | define('seajs/plugin-text', ['./plugin-base'], function(require) {
|
5 |
|
6 | var plugin = require('./plugin-base')
|
7 | var util = plugin.util
|
8 |
|
9 |
|
10 | plugin.add({
|
11 | name: 'text',
|
12 |
|
13 | ext: ['.tpl', '.htm', '.html'],
|
14 |
|
15 | fetch: function(url, callback) {
|
16 | util.xhr(url, function(data) {
|
17 | var str = jsEscape(data)
|
18 | util.globalEval('define([], "' + str + '")')
|
19 | callback()
|
20 | })
|
21 | }
|
22 | })
|
23 |
|
24 |
|
25 | function jsEscape(s) {
|
26 | return s.replace(/(["\\])/g, '\\$1')
|
27 | .replace(/\r/g, "\\r")
|
28 | .replace(/\n/g, "\\n")
|
29 | .replace(/\t/g, "\\t")
|
30 | .replace(/\f/g, "\\f")
|
31 | }
|
32 |
|
33 | });
|
34 |
|