-
Notifications
You must be signed in to change notification settings - Fork 50
/
dtl.js.uncompressed.js
2855 lines (2589 loc) · 78.9 KB
/
dtl.js.uncompressed.js
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (c) 2004-2009, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
/*
This is a compiled version of Dojo, built for deployment and not for
development. To get an editable version, please visit:
http://dojotoolkit.org
for documentation and information on getting the source.
*/
if(!dojo._hasResource["dojox.string.Builder"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.string.Builder"] = true;
dojo.provide("dojox.string.Builder");
dojox.string.Builder = function(/*String?*/str){
// summary:
// A fast buffer for creating large strings.
//
// length: Number
// The current length of the internal string.
// N.B. the public nature of the internal buffer is no longer
// needed because the IE-specific fork is no longer needed--TRT.
var b = "";
this.length = 0;
this.append = function(/* String... */s){
// summary: Append all arguments to the end of the buffer
if(arguments.length>1){
/*
This is a loop unroll was designed specifically for Firefox;
it would seem that static index access on an Arguments
object is a LOT faster than doing dynamic index access.
Therefore, we create a buffer string and take advantage
of JS's switch fallthrough. The peformance of this method
comes very close to straight up string concatenation (+=).
If the arguments object length is greater than 9, we fall
back to standard dynamic access.
This optimization seems to have no real effect on either
Safari or Opera, so we just use it for all.
It turns out also that this loop unroll can increase performance
significantly with Internet Explorer, particularly when
as many arguments are provided as possible.
Loop unroll per suggestion from Kris Zyp, implemented by
Tom Trenka.
Note: added empty string to force a string cast if needed.
*/
var tmp="", l=arguments.length;
switch(l){
case 9: tmp=""+arguments[8]+tmp;
case 8: tmp=""+arguments[7]+tmp;
case 7: tmp=""+arguments[6]+tmp;
case 6: tmp=""+arguments[5]+tmp;
case 5: tmp=""+arguments[4]+tmp;
case 4: tmp=""+arguments[3]+tmp;
case 3: tmp=""+arguments[2]+tmp;
case 2: {
b+=""+arguments[0]+arguments[1]+tmp;
break;
}
default: {
var i=0;
while(i<arguments.length){
tmp += arguments[i++];
}
b += tmp;
}
}
} else {
b += s;
}
this.length = b.length;
return this; // dojox.string.Builder
};
this.concat = function(/*String...*/s){
// summary:
// Alias for append.
return this.append.apply(this, arguments); // dojox.string.Builder
};
this.appendArray = function(/*Array*/strings) {
// summary:
// Append an array of items to the internal buffer.
// Changed from String.prototype.concat.apply because of IE.
return this.append.apply(this, strings); // dojox.string.Builder
};
this.clear = function(){
// summary:
// Remove all characters from the buffer.
b = "";
this.length = 0;
return this; // dojox.string.Builder
};
this.replace = function(/* String */oldStr, /* String */ newStr){
// summary:
// Replace instances of one string with another in the buffer.
b = b.replace(oldStr,newStr);
this.length = b.length;
return this; // dojox.string.Builder
};
this.remove = function(/* Number */start, /* Number? */len){
// summary:
// Remove len characters starting at index start. If len
// is not provided, the end of the string is assumed.
if(len===undefined){ len = b.length; }
if(len == 0){ return this; }
b = b.substr(0, start) + b.substr(start+len);
this.length = b.length;
return this; // dojox.string.Builder
};
this.insert = function(/* Number */index, /* String */str){
// summary:
// Insert string str starting at index.
if(index == 0){
b = str + b;
}else{
b = b.slice(0, index) + str + b.slice(index);
}
this.length = b.length;
return this; // dojox.string.Builder
};
this.toString = function(){
// summary:
// Return the string representation of the internal buffer.
return b; // String
};
// initialize the buffer.
if(str){ this.append(str); }
};
}
if(!dojo._hasResource["dojox.string.tokenize"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.string.tokenize"] = true;
dojo.provide("dojox.string.tokenize");
dojox.string.tokenize = function(/*String*/ str, /*RegExp*/ re, /*Function?*/ parseDelim, /*Object?*/ instance){
// summary:
// Split a string by a regular expression with the ability to capture the delimeters
// parseDelim:
// Each group (excluding the 0 group) is passed as a parameter. If the function returns
// a value, it's added to the list of tokens.
// instance:
// Used as the "this" instance when calling parseDelim
var tokens = [];
var match, content, lastIndex = 0;
while(match = re.exec(str)){
content = str.slice(lastIndex, re.lastIndex - match[0].length);
if(content.length){
tokens.push(content);
}
if(parseDelim){
if(dojo.isOpera){
var copy = match.slice(0);
while(copy.length < match.length){
copy.push(null);
}
match = copy;
}
var parsed = parseDelim.apply(instance, match.slice(1).concat(tokens.length));
if(typeof parsed != "undefined"){
tokens.push(parsed);
}
}
lastIndex = re.lastIndex;
}
content = str.slice(lastIndex);
if(content.length){
tokens.push(content);
}
return tokens;
}
}
if(!dojo._hasResource["dojox.dtl._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl._base"] = true;
dojo.provide("dojox.dtl._base");
dojo.experimental("dojox.dtl");
(function(){
var dd = dojox.dtl;
dd.TOKEN_BLOCK = -1;
dd.TOKEN_VAR = -2;
dd.TOKEN_COMMENT = -3;
dd.TOKEN_TEXT = 3;
dd._Context = dojo.extend(function(dict){
// summary: Pass one of these when rendering a template to tell the template what values to use.
dojo._mixin(this, dict || {});
this._dicts = [];
},
{
push: function(){
var last = this;
var context = dojo.delegate(this);
context.pop = function(){ return last; }
return context;
},
pop: function(){
throw new Error("pop() called on empty Context");
},
get: function(key, otherwise){
if(typeof this[key] != "undefined"){
return this._normalize(this[key]);
}
for(var i = 0, dict; dict = this._dicts[i]; i++){
if(typeof dict[key] != "undefined"){
return this._normalize(dict[key]);
}
}
return otherwise;
},
_normalize: function(value){
if(value instanceof Date){
value.year = value.getFullYear();
value.month = value.getMonth() + 1;
value.day = value.getDate();
value.date = value.year + "-" + ("0" + value.month).slice(-2) + "-" + ("0" + value.day).slice(-2);
value.hour = value.getHours();
value.minute = value.getMinutes();
value.second = value.getSeconds();
value.microsecond = value.getMilliseconds();
}
return value;
},
update: function(dict){
var context = this.push();
if(dict){
dojo._mixin(this, dict);
}
return context;
}
});
var smart_split_re = /("(?:[^"\\]*(?:\\.[^"\\]*)*)"|'(?:[^'\\]*(?:\\.[^'\\]*)*)'|[^\s]+)/g;
var split_re = /\s+/g;
var split = function(/*String|RegExp?*/ splitter, /*Integer?*/ limit){
splitter = splitter || split_re;
if(!(splitter instanceof RegExp)){
splitter = new RegExp(splitter, "g");
}
if(!splitter.global){
throw new Error("You must use a globally flagged RegExp with split " + splitter);
}
splitter.exec(""); // Reset the global
var part, parts = [], lastIndex = 0, i = 0;
while(part = splitter.exec(this)){
parts.push(this.slice(lastIndex, splitter.lastIndex - part[0].length));
lastIndex = splitter.lastIndex;
if(limit && (++i > limit - 1)){
break;
}
}
parts.push(this.slice(lastIndex));
return parts;
}
dd.Token = function(token_type, contents){
this.token_type = token_type;
this.contents = new String(dojo.trim(contents));
this.contents.split = split;
this.split = function(){
return String.prototype.split.apply(this.contents, arguments);
}
}
dd.Token.prototype.split_contents = function(/*Integer?*/ limit){
var bit, bits = [], i = 0;
limit = limit || 999;
while(i++ < limit && (bit = smart_split_re.exec(this.contents))){
bit = bit[0];
if(bit.charAt(0) == '"' && bit.slice(-1) == '"'){
bits.push('"' + bit.slice(1, -1).replace('\\"', '"').replace('\\\\', '\\') + '"');
}else if(bit.charAt(0) == "'" && bit.slice(-1) == "'"){
bits.push("'" + bit.slice(1, -1).replace("\\'", "'").replace('\\\\', '\\') + "'");
}else{
bits.push(bit);
}
}
return bits;
}
var ddt = dd.text = {
_get: function(module, name, errorless){
// summary: Used to find both tags and filters
var params = dd.register.get(module, name.toLowerCase(), errorless);
if(!params){
if(!errorless){
throw new Error("No tag found for " + name);
}
return null;
}
var fn = params[1];
var require = params[2];
var parts;
if(fn.indexOf(":") != -1){
parts = fn.split(":");
fn = parts.pop();
}
dojo["require"](require);
var parent = dojo.getObject(require);
return parent[fn || name] || parent[name + "_"] || parent[fn + "_"];
},
getTag: function(name, errorless){
return ddt._get("tag", name, errorless);
},
getFilter: function(name, errorless){
return ddt._get("filter", name, errorless);
},
getTemplate: function(file){
return new dd.Template(ddt.getTemplateString(file));
},
getTemplateString: function(file){
return dojo._getText(file.toString()) || "";
},
_resolveLazy: function(location, sync, json){
if(sync){
if(json){
return dojo.fromJson(dojo._getText(location)) || {};
}else{
return dd.text.getTemplateString(location);
}
}else{
return dojo.xhrGet({
handleAs: (json) ? "json" : "text",
url: location
});
}
},
_resolveTemplateArg: function(arg, sync){
if(ddt._isTemplate(arg)){
if(!sync){
var d = new dojo.Deferred();
d.callback(arg);
return d;
}
return arg;
}
return ddt._resolveLazy(arg, sync);
},
_isTemplate: function(arg){
return (typeof arg == "undefined") || (typeof arg == "string" && (arg.match(/^\s*[<{]/) || arg.indexOf(" ") != -1));
},
_resolveContextArg: function(arg, sync){
if(arg.constructor == Object){
if(!sync){
var d = new dojo.Deferred;
d.callback(arg);
return d;
}
return arg;
}
return ddt._resolveLazy(arg, sync, true);
},
_re: /(?:\{\{\s*(.+?)\s*\}\}|\{%\s*(load\s*)?(.+?)\s*%\})/g,
tokenize: function(str){
return dojox.string.tokenize(str, ddt._re, ddt._parseDelims);
},
_parseDelims: function(varr, load, tag){
if(varr){
return [dd.TOKEN_VAR, varr];
}else if(load){
var parts = dojo.trim(tag).split(/\s+/g);
for(var i = 0, part; part = parts[i]; i++){
dojo["require"](part);
}
}else{
return [dd.TOKEN_BLOCK, tag];
}
}
}
dd.Template = dojo.extend(function(/*String|dojo._Url*/ template, /*Boolean*/ isString){
// template:
// The string or location of the string to
// use as a template
var str = isString ? template : ddt._resolveTemplateArg(template, true) || "";
var tokens = ddt.tokenize(str);
var parser = new dd._Parser(tokens);
this.nodelist = parser.parse();
},
{
update: function(node, context){
// node: DOMNode|String|dojo.NodeList
// A node reference or set of nodes
// context: dojo._Url|String|Object
// The context object or location
return ddt._resolveContextArg(context).addCallback(this, function(contextObject){
var content = this.render(new dd._Context(contextObject));
if(node.forEach){
node.forEach(function(item){
item.innerHTML = content;
});
}else{
dojo.byId(node).innerHTML = content;
}
return this;
});
},
render: function(context, /*concatenatable?*/ buffer){
buffer = buffer || this.getBuffer();
context = context || new dd._Context({});
return this.nodelist.render(context, buffer) + "";
},
getBuffer: function(){
return new dojox.string.Builder();
}
});
var qfRe = /\{\{\s*(.+?)\s*\}\}/g;
dd.quickFilter = function(str){
if(!str){
return new dd._NodeList();
}
if(str.indexOf("{%") == -1){
return new dd._QuickNodeList(dojox.string.tokenize(str, qfRe, function(token){
return new dd._Filter(token);
}));
}
}
dd._QuickNodeList = dojo.extend(function(contents){
this.contents = contents;
},
{
render: function(context, buffer){
for(var i=0, l=this.contents.length; i<l; i++){
if(this.contents[i].resolve){
buffer = buffer.concat(this.contents[i].resolve(context));
}else{
buffer = buffer.concat(this.contents[i]);
}
}
return buffer;
},
dummyRender: function(context){ return this.render(context, dd.Template.prototype.getBuffer()).toString(); },
clone: function(buffer){ return this; }
});
dd._Filter = dojo.extend(function(token){
// summary: Uses a string to find (and manipulate) a variable
if(!token) throw new Error("Filter must be called with variable name");
this.contents = token;
var cache = this._cache[token];
if(cache){
this.key = cache[0];
this.filters = cache[1];
}else{
this.filters = [];
dojox.string.tokenize(token, this._re, this._tokenize, this);
this._cache[token] = [this.key, this.filters];
}
},
{
_cache: {},
_re: /(?:^_\("([^\\"]*(?:\\.[^\\"])*)"\)|^"([^\\"]*(?:\\.[^\\"]*)*)"|^([a-zA-Z0-9_.]+)|\|(\w+)(?::(?:_\("([^\\"]*(?:\\.[^\\"])*)"\)|"([^\\"]*(?:\\.[^\\"]*)*)"|([a-zA-Z0-9_.]+)|'([^\\']*(?:\\.[^\\']*)*)'))?|^'([^\\']*(?:\\.[^\\']*)*)')/g,
_values: {
0: '"', // _("text")
1: '"', // "text"
2: "", // variable
8: '"' // 'text'
},
_args: {
4: '"', // :_("text")
5: '"', // :"text"
6: "", // :variable
7: "'"// :'text'
},
_tokenize: function(){
var pos, arg;
for(var i = 0, has = []; i < arguments.length; i++){
has[i] = (typeof arguments[i] != "undefined" && typeof arguments[i] == "string" && arguments[i]);
}
if(!this.key){
for(pos in this._values){
if(has[pos]){
this.key = this._values[pos] + arguments[pos] + this._values[pos];
break;
}
}
}else{
for(pos in this._args){
if(has[pos]){
var value = arguments[pos];
if(this._args[pos] == "'"){
value = value.replace(/\\'/g, "'");
}else if(this._args[pos] == '"'){
value = value.replace(/\\"/g, '"');
}
arg = [!this._args[pos], value];
break;
}
}
// Get a named filter
var fn = ddt.getFilter(arguments[3]);
if(!dojo.isFunction(fn)) throw new Error(arguments[3] + " is not registered as a filter");
this.filters.push([fn, arg]);
}
},
getExpression: function(){
return this.contents;
},
resolve: function(context){
if(typeof this.key == "undefined"){
return "";
}
var str = this.resolvePath(this.key, context);
for(var i = 0, filter; filter = this.filters[i]; i++){
// Each filter has the function in [0], a boolean in [1][0] of whether it's a variable or a string
// and [1][1] is either the variable name of the string content.
if(filter[1]){
if(filter[1][0]){
str = filter[0](str, this.resolvePath(filter[1][1], context));
}else{
str = filter[0](str, filter[1][1]);
}
}else{
str = filter[0](str);
}
}
return str;
},
resolvePath: function(path, context){
var current, parts;
var first = path.charAt(0);
var last = path.slice(-1);
if(!isNaN(parseInt(first))){
current = (path.indexOf(".") == -1) ? parseInt(path) : parseFloat(path);
}else if(first == '"' && first == last){
current = path.slice(1, -1);
}else{
if(path == "true"){ return true; }
if(path == "false"){ return false; }
if(path == "null" || path == "None"){ return null; }
parts = path.split(".");
current = context.get(parts[0]);
if(dojo.isFunction(current)){
var self = context.getThis && context.getThis();
if(current.alters_data){
current = "";
}else if(self){
current = current.call(self);
}else{
current = "";
}
}
for(var i = 1; i < parts.length; i++){
var part = parts[i];
if(current){
var base = current;
if(dojo.isObject(current) && part == "items" && typeof current[part] == "undefined"){
var items = [];
for(var key in current){
items.push([key, current[key]]);
}
current = items;
continue;
}
if(current.get && dojo.isFunction(current.get) && current.get.safe){
current = current.get(part);
}else if(typeof current[part] == "undefined"){
current = current[part];
break;
}else{
current = current[part];
}
if(dojo.isFunction(current)){
if(current.alters_data){
current = "";
}else{
current = current.call(base);
}
}else if(current instanceof Date){
current = dd._Context.prototype._normalize(current);
}
}else{
return "";
}
}
}
return current;
}
});
dd._TextNode = dd._Node = dojo.extend(function(/*Object*/ obj){
// summary: Basic catch-all node
this.contents = obj;
},
{
set: function(data){
this.contents = data;
return this;
},
render: function(context, buffer){
// summary: Adds content onto the buffer
return buffer.concat(this.contents);
},
isEmpty: function(){
return !dojo.trim(this.contents);
},
clone: function(){ return this; }
});
dd._NodeList = dojo.extend(function(/*Node[]*/ nodes){
// summary: Allows us to render a group of nodes
this.contents = nodes || [];
this.last = "";
},
{
push: function(node){
// summary: Add a new node to the list
this.contents.push(node);
return this;
},
concat: function(nodes){
this.contents = this.contents.concat(nodes);
return this;
},
render: function(context, buffer){
// summary: Adds all content onto the buffer
for(var i = 0; i < this.contents.length; i++){
buffer = this.contents[i].render(context, buffer);
if(!buffer) throw new Error("Template must return buffer");
}
return buffer;
},
dummyRender: function(context){
return this.render(context, dd.Template.prototype.getBuffer()).toString();
},
unrender: function(){ return arguments[1]; },
clone: function(){ return this; },
rtrim: function(){
while(1){
i = this.contents.length - 1;
if(this.contents[i] instanceof dd._TextNode && this.contents[i].isEmpty()){
this.contents.pop();
}else{
break;
}
}
return this;
}
});
dd._VarNode = dojo.extend(function(str){
// summary: A node to be processed as a variable
this.contents = new dd._Filter(str);
},
{
render: function(context, buffer){
var str = this.contents.resolve(context);
if(!str.safe){
str = dd._base.escape("" + str);
}
return buffer.concat(str);
}
});
dd._noOpNode = new function(){
// summary: Adds a no-op node. Useful in custom tags
this.render = this.unrender = function(){ return arguments[1]; }
this.clone = function(){ return this; }
}
dd._Parser = dojo.extend(function(tokens){
// summary: Parser used during initialization and for tag groups.
this.contents = tokens;
},
{
i: 0,
parse: function(/*Array?*/ stop_at){
// summary: Turns tokens into nodes
// description: Steps into tags are they're found. Blocks use the parse object
// to find their closing tag (the stop_at array). stop_at is inclusive, it
// returns the node that matched.
var terminators = {}, token;
stop_at = stop_at || [];
for(var i = 0; i < stop_at.length; i++){
terminators[stop_at[i]] = true;
}
var nodelist = new dd._NodeList();
while(this.i < this.contents.length){
token = this.contents[this.i++];
if(typeof token == "string"){
nodelist.push(new dd._TextNode(token));
}else{
var type = token[0];
var text = token[1];
if(type == dd.TOKEN_VAR){
nodelist.push(new dd._VarNode(text));
}else if(type == dd.TOKEN_BLOCK){
if(terminators[text]){
--this.i;
return nodelist;
}
var cmd = text.split(/\s+/g);
if(cmd.length){
cmd = cmd[0];
var fn = ddt.getTag(cmd);
if(fn){
nodelist.push(fn(this, new dd.Token(type, text)));
}
}
}
}
}
if(stop_at.length){
throw new Error("Could not find closing tag(s): " + stop_at.toString());
}
this.contents.length = 0;
return nodelist;
},
next_token: function(){
// summary: Returns the next token in the list.
var token = this.contents[this.i++];
return new dd.Token(token[0], token[1]);
},
delete_first_token: function(){
this.i++;
},
skip_past: function(endtag){
while(this.i < this.contents.length){
var token = this.contents[this.i++];
if(token[0] == dd.TOKEN_BLOCK && token[1] == endtag){
return;
}
}
throw new Error("Unclosed tag found when looking for " + endtag);
},
create_variable_node: function(expr){
return new dd._VarNode(expr);
},
create_text_node: function(expr){
return new dd._TextNode(expr || "");
},
getTemplate: function(file){
return new dd.Template(file);
}
});
dd.register = {
_registry: {
attributes: [],
tags: [],
filters: []
},
get: function(/*String*/ module, /*String*/ name){
var registry = dd.register._registry[module + "s"];
for(var i = 0, entry; entry = registry[i]; i++){
if(typeof entry[0] == "string"){
if(entry[0] == name){
return entry;
}
}else if(name.match(entry[0])){
return entry;
}
}
},
getAttributeTags: function(){
var tags = [];
var registry = dd.register._registry.attributes;
for(var i = 0, entry; entry = registry[i]; i++){
if(entry.length == 3){
tags.push(entry);
}else{
var fn = dojo.getObject(entry[1]);
if(fn && dojo.isFunction(fn)){
entry.push(fn);
tags.push(entry);
}
}
}
return tags;
},
_any: function(type, base, locations){
for(var path in locations){
for(var i = 0, fn; fn = locations[path][i]; i++){
var key = fn;
if(dojo.isArray(fn)){
key = fn[0];
fn = fn[1];
}
if(typeof key == "string"){
if(key.substr(0, 5) == "attr:"){
var attr = fn;
if(attr.substr(0, 5) == "attr:"){
attr = attr.slice(5);
}
dd.register._registry.attributes.push([attr.toLowerCase(), base + "." + path + "." + attr]);
}
key = key.toLowerCase()
}
dd.register._registry[type].push([
key,
fn,
base + "." + path
]);
}
}
},
tags: function(/*String*/ base, /*Object*/ locations){
dd.register._any("tags", base, locations);
},
filters: function(/*String*/ base, /*Object*/ locations){
dd.register._any("filters", base, locations);
}
}
var escapeamp = /&/g;
var escapelt = /</g;
var escapegt = />/g;
var escapeqt = /'/g;
var escapedblqt = /"/g;
dd._base.escape = function(value){
// summary: Escapes a string's HTML
return dd.mark_safe(value.replace(escapeamp, '&').replace(escapelt, '<').replace(escapegt, '>').replace(escapedblqt, '"').replace(escapeqt, '''));
}
dd._base.safe = function(value){
if(typeof value == "string"){
value = new String(value);
}
if(typeof value == "object"){
value.safe = true;
}
return value;
}
dd.mark_safe = dd._base.safe;
dd.register.tags("dojox.dtl.tag", {
"date": ["now"],
"logic": ["if", "for", "ifequal", "ifnotequal"],
"loader": ["extends", "block", "include", "load", "ssi"],
"misc": ["comment", "debug", "filter", "firstof", "spaceless", "templatetag", "widthratio", "with"],
"loop": ["cycle", "ifchanged", "regroup"]
});
dd.register.filters("dojox.dtl.filter", {
"dates": ["date", "time", "timesince", "timeuntil"],
"htmlstrings": ["linebreaks", "linebreaksbr", "removetags", "striptags"],
"integers": ["add", "get_digit"],
"lists": ["dictsort", "dictsortreversed", "first", "join", "length", "length_is", "random", "slice", "unordered_list"],
"logic": ["default", "default_if_none", "divisibleby", "yesno"],
"misc": ["filesizeformat", "pluralize", "phone2numeric", "pprint"],
"strings": ["addslashes", "capfirst", "center", "cut", "fix_ampersands", "floatformat", "iriencode", "linenumbers", "ljust", "lower", "make_list", "rjust", "slugify", "stringformat", "title", "truncatewords", "truncatewords_html", "upper", "urlencode", "urlize", "urlizetrunc", "wordcount", "wordwrap"]
});
dd.register.filters("dojox.dtl", {
"_base": ["escape", "safe"]
});
})();
}
if(!dojo._hasResource["dojox.dtl"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl"] = true;
dojo.provide("dojox.dtl");
}
if(!dojo._hasResource["dojox.dtl.Context"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.Context"] = true;
dojo.provide("dojox.dtl.Context");
dojox.dtl.Context = dojo.extend(function(dict){
this._this = {};
dojox.dtl._Context.call(this, dict);
}, dojox.dtl._Context.prototype,
{
getKeys: function(){
var keys = [];
for(var key in this){
if(this.hasOwnProperty(key) && key != "_dicts" && key != "_this"){
keys.push(key);
}
}
return keys;
},
extend: function(/*dojox.dtl.Context|Object*/ obj){
// summary: Returns a clone of this context object, with the items from the
// passed objecct mixed in.
return dojo.delegate(this, obj);
},
filter: function(/*dojox.dtl.Context|Object|String...*/ filter){
// summary: Returns a clone of this context, only containing the items
// defined in the filter.
var context = new dojox.dtl.Context();
var keys = [];
var i, arg;
if(filter instanceof dojox.dtl.Context){
keys = filter.getKeys();
}else if(typeof filter == "object"){
for(var key in filter){
keys.push(key);
}
}else{
for(i = 0; arg = arguments[i]; i++){
if(typeof arg == "string"){
keys.push(arg);
}
}
}
for(i = 0, key; key = keys[i]; i++){
context[key] = this[key];
}
return context;
},
setThis: function(/*Object*/ _this){
this._this = _this;
},
getThis: function(){
return this._this;
},
hasKey: function(key){
if(typeof this[key] != "undefined"){
return true;
}
for(var i = 0, dict; dict = this._dicts[i]; i++){
if(typeof dict[key] != "undefined"){
return true;
}
}
return false;
}
});
}
if(!dojo._hasResource["dojox.dtl.tag.logic"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.dtl.tag.logic"] = true;
dojo.provide("dojox.dtl.tag.logic");
(function(){
var dd = dojox.dtl;
var ddt = dd.text;
var ddtl = dd.tag.logic;
ddtl.IfNode = dojo.extend(function(bools, trues, falses, type){
this.bools = bools;
this.trues = trues;
this.falses = falses;
this.type = type;
},
{
render: function(context, buffer){
var i, bool, ifnot, filter, value;
if(this.type == "or"){