forked from requirejs/requirejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextBuilt.js
More file actions
64 lines (58 loc) · 1.81 KB
/
textBuilt.js
File metadata and controls
64 lines (58 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(function () {
define('text',[],function () {
var text = {
load: function (name, req, onLoad, config) {
throw "THE TEXT PLUGIN LOAD() FUNCTION SHOULD NOT BE CALLED";
}
};
return text;
});
}());
define('text!subwidget.html!strip', function () { return '<div data-type="subwidget"><h1>This is a subwidget</h1></div>';});
define('text!subwidget2.html', function () { return '<span>This! is template2</span>';});
define("subwidget",
["text!subwidget.html!strip", "text!subwidget2.html"],
function(template, template2) {
return {
name: "subwidget",
template: template,
template2: template2
};
}
);
define('text!widget.html', function () { return '<div data-type="widget"><h1>This is a widget!</h1><p>I am in a widget</p></div>';});
define("widget",
["subwidget", "text!widget.html"],
function(subwidget, template) {
return {
subWidgetName: subwidget.name,
subWidgetTemplate: subwidget.template,
subWidgetTemplate2: subwidget.template2,
template: template
};
}
);
/****************** TEST CODE IS BELOW ******************/
require({
baseUrl: "./",
paths: {
text: "../../../text/text"
}
});
require(
["widget"],
function(widget) {
doh.register(
"text",
[
function text(t){
t.is('<div data-type="widget"><h1>This is a widget!</h1><p>I am in a widget</p></div>', widget.template);
t.is('subwidget', widget.subWidgetName);
t.is('<div data-type="subwidget"><h1>This is a subwidget</h1></div>', widget.subWidgetTemplate);
t.is('<span>This! is template2</span>', widget.subWidgetTemplate2);
}
]
);
doh.run();
}
);