/
dust.js
898 lines (803 loc) · 23.3 KB
/
dust.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
/*jshint evil:true*/
(function(root) {
var dust = {
"version": "2.5.1"
},
NONE = 'NONE',
ERROR = 'ERROR',
WARN = 'WARN',
INFO = 'INFO',
DEBUG = 'DEBUG',
loggingLevels = [DEBUG, INFO, WARN, ERROR, NONE],
EMPTY_FUNC = function() {},
logger = {},
originalLog,
loggerContext;
dust.debugLevel = NONE;
dust.config = {
whitespace: false
};
// Directive aliases to minify code
dust._aliases = {
"write": "w",
"end": "e",
"map": "m",
"render": "r",
"reference": "f",
"section": "s",
"exists": "x",
"notexists": "nx",
"block": "b",
"partial": "p",
"helper": "h"
};
// Try to find the console in global scope
if (root && root.console && root.console.log) {
loggerContext = root.console;
originalLog = root.console.log;
}
// robust logger for node.js, modern browsers, and IE <= 9.
logger.log = loggerContext ? function() {
// Do this for normal browsers
if (typeof originalLog === 'function') {
logger.log = function() {
originalLog.apply(loggerContext, arguments);
};
} else {
// Do this for IE <= 9
logger.log = function() {
var message = Array.prototype.slice.apply(arguments).join(' ');
originalLog(message);
};
}
logger.log.apply(this, arguments);
} : function() { /* no op */ };
/**
* Log dust debug statements, info statements, warning statements, and errors.
* Filters out the messages based on the dust.debuglevel.
* This default implementation will print to the console if it exists.
* @param {String|Error} message the message to print/throw
* @param {String} type the severity of the message(ERROR, WARN, INFO, or DEBUG)
* @public
*/
dust.log = function(message, type) {
type = type || INFO;
if (dust.debugLevel !== NONE && dust.indexInArray(loggingLevels, type) >= dust.indexInArray(loggingLevels, dust.debugLevel)) {
if(!dust.logQueue) {
dust.logQueue = [];
}
dust.logQueue.push({message: message, type: type});
logger.log('[DUST:' + type + ']', message);
}
};
dust.helpers = {};
dust.cache = {};
dust.register = function(name, tmpl) {
if (!name) {
return;
}
dust.cache[name] = tmpl;
};
dust.render = function(name, context, callback) {
var chunk = new Stub(callback).head;
try {
dust.load(name, chunk, Context.wrap(context, name)).end();
} catch (err) {
chunk.setError(err);
}
};
dust.stream = function(name, context) {
var stream = new Stream(),
chunk = stream.head;
dust.nextTick(function() {
try {
dust.load(name, stream.head, Context.wrap(context, name)).end();
} catch (err) {
chunk.setError(err);
}
});
return stream;
};
dust.renderSource = function(source, context, callback) {
return dust.compileFn(source)(context, callback);
};
dust.compileFn = function(source, name) {
// name is optional. When name is not provided the template can only be rendered using the callable returned by this function.
// If a name is provided the compiled template can also be rendered by name.
name = name || null;
var tmpl = dust.loadSource(dust.compile(source, name));
return function(context, callback) {
var master = callback ? new Stub(callback) : new Stream();
dust.nextTick(function() {
if(typeof tmpl === 'function') {
tmpl(master.head, Context.wrap(context, name)).end();
}
else {
dust.log(new Error('Template [' + name + '] cannot be resolved to a Dust function'), ERROR);
}
});
return master;
};
};
dust.load = function(name, chunk, context) {
var tmpl = dust.cache[name];
if (tmpl) {
return tmpl(chunk, context);
} else {
if (dust.onLoad) {
return chunk.map(function(chunk) {
dust.onLoad(name, function(err, src) {
if (err) {
return chunk.setError(err);
}
if (!dust.cache[name]) {
dust.loadSource(dust.compile(src, name));
}
dust.cache[name](chunk, context).end();
});
});
}
return chunk.setError(new Error('Template Not Found: ' + name));
}
};
dust.loadSource = function(source, path) {
return eval(source);
};
if (Array.isArray) {
dust.isArray = Array.isArray;
} else {
dust.isArray = function(arr) {
return Object.prototype.toString.call(arr) === '[object Array]';
};
}
// indexOf shim for arrays for IE <= 8
// source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
dust.indexInArray = function(arr, item, fromIndex) {
fromIndex = +fromIndex || 0;
if (Array.prototype.indexOf) {
return arr.indexOf(item, fromIndex);
} else {
if ( arr === undefined || arr === null ) {
throw new TypeError( 'cannot call method "indexOf" of null' );
}
var length = arr.length; // Hack to convert object.length to a UInt32
if (Math.abs(fromIndex) === Infinity) {
fromIndex = 0;
}
if (fromIndex < 0) {
fromIndex += length;
if (fromIndex < 0) {
fromIndex = 0;
}
}
for (;fromIndex < length; fromIndex++) {
if (arr[fromIndex] === item) {
return fromIndex;
}
}
return -1;
}
};
dust.nextTick = (function() {
return function(callback) {
setTimeout(callback,0);
};
} )();
dust.isEmpty = function(value) {
if (dust.isArray(value) && !value.length) {
return true;
}
if (value === 0) {
return false;
}
return (!value);
};
// apply the filter chain and return the output string
dust.filter = function(string, auto, filters) {
if (filters) {
for (var i=0, len=filters.length; i<len; i++) {
var name = filters[i];
if (name === 's') {
auto = null;
}
else if (typeof dust.filters[name] === 'function') {
string = dust.filters[name](string);
}
else {
dust.log('Invalid filter [' + name + ']', WARN);
}
}
}
// by default always apply the h filter, unless asked to unescape with |s
if (auto) {
string = dust.filters[auto](string);
}
return string;
};
dust.filters = {
h: function(value) { return dust.escapeHtml(value); },
j: function(value) { return dust.escapeJs(value); },
u: encodeURI,
uc: encodeURIComponent,
js: function(value) {
if (!JSON) {
dust.log('JSON is undefined. JSON stringify has not been used on [' + value + ']', WARN);
return value;
} else {
return JSON.stringify(value);
}
},
jp: function(value) {
if (!JSON) {dust.log('JSON is undefined. JSON parse has not been used on [' + value + ']', WARN);
return value;
} else {
return JSON.parse(value);
}
}
};
function Context(stack, global, blocks, templateName) {
this.stack = stack;
this.global = global;
this.blocks = blocks;
this.templateName = templateName;
}
dust.makeBase = function(global) {
return new Context(new Stack(), global);
};
Context.wrap = function(context, name) {
if (context instanceof Context) {
return context;
}
return new Context(new Stack(context), {}, null, name);
};
/**
* Public API for getting a value from the context.
* @method get
* @param {string|array} path The path to the value. Supported formats are:
* 'key'
* 'path.to.key'
* '.path.to.key'
* ['path', 'to', 'key']
* ['key']
* @param {boolean} [cur=false] Boolean which determines if the search should be limited to the
* current context (true), or if get should search in parent contexts as well (false).
* @public
* @returns {string|object}
*/
Context.prototype.get = function(path, cur) {
if (typeof path === 'string') {
if (path[0] === '.') {
cur = true;
path = path.substr(1);
}
path = path.split('.');
}
return this._get(cur, path);
};
/**
* Get a value from the context
* @method _get
* @param {boolean} cur Get only from the current context
* @param {array} down An array of each step in the path
* @private
* @return {string | object}
*/
Context.prototype._get = function(cur, down) {
var ctx = this.stack,
i = 1,
value, first, len, ctxThis, fn;
first = down[0];
len = down.length;
if (cur && len === 0) {
ctxThis = ctx;
ctx = ctx.head;
} else {
if (!cur) {
// Search up the stack for the first value
while (ctx) {
if (ctx.isObject) {
ctxThis = ctx.head;
value = ctx.head[first];
if (value !== undefined) {
break;
}
}
ctx = ctx.tail;
}
if (value !== undefined) {
ctx = value;
} else {
ctx = this.global ? this.global[first] : undefined;
}
} else if (ctx) {
// if scope is limited by a leading dot, don't search up the tree
if(ctx.head) {
ctx = ctx.head[first];
} else {
//context's head is empty, value we are searching for is not defined
ctx = undefined;
}
}
while (ctx && i < len) {
ctxThis = ctx;
ctx = ctx[down[i]];
i++;
}
}
// Return the ctx or a function wrapping the application of the context.
if (typeof ctx === 'function') {
fn = function() {
try {
return ctx.apply(ctxThis, arguments);
} catch (err) {
dust.log(err, ERROR);
throw err;
}
};
fn.__dustBody = !!ctx.__dustBody;
return fn;
} else {
if (ctx === undefined) {
dust.log('Cannot find the value for reference [{' + down.join('.') + '}] in template [' + this.getTemplateName() + ']');
}
return ctx;
}
};
Context.prototype.getPath = function(cur, down) {
return this._get(cur, down);
};
Context.prototype.push = function(head, idx, len) {
return new Context(new Stack(head, this.stack, idx, len), this.global, this.blocks, this.getTemplateName());
};
Context.prototype.rebase = function(head) {
return new Context(new Stack(head), this.global, this.blocks, this.getTemplateName());
};
Context.prototype.current = function() {
return this.stack.head;
};
Context.prototype.getBlock = function(key, chk, ctx) {
if (typeof key === 'function') {
var tempChk = new Chunk();
key = key(tempChk, this).data.join('');
}
var blocks = this.blocks;
if (!blocks) {
dust.log('No blocks for context[{' + key + '}] in template [' + this.getTemplateName() + ']', DEBUG);
return;
}
var len = blocks.length, fn;
while (len--) {
fn = blocks[len][key];
if (fn) {
return fn;
}
}
};
Context.prototype.shiftBlocks = function(locals) {
var blocks = this.blocks,
newBlocks;
if (locals) {
if (!blocks) {
newBlocks = [locals];
} else {
newBlocks = blocks.concat([locals]);
}
return new Context(this.stack, this.global, newBlocks, this.getTemplateName());
}
return this;
};
Context.prototype.getTemplateName = function() {
return this.templateName;
};
function Stack(head, tail, idx, len) {
this.tail = tail;
this.isObject = head && typeof head === 'object';
this.head = head;
this.index = idx;
this.of = len;
}
function Stub(callback) {
this.head = new Chunk(this);
this.callback = callback;
this.out = '';
}
Stub.prototype.flush = function() {
var chunk = this.head;
while (chunk) {
if (chunk.flushable) {
this.out += chunk.data.join(''); //ie7 perf
} else if (chunk.error) {
this.callback(chunk.error);
dust.log('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.', WARN);
this.flush = EMPTY_FUNC;
return;
} else {
return;
}
chunk = chunk.next;
this.head = chunk;
}
this.callback(null, this.out);
};
function Stream() {
this.head = new Chunk(this);
}
Stream.prototype.flush = function() {
var chunk = this.head;
while(chunk) {
if (chunk.flushable) {
this.emit('data', chunk.data.join('')); //ie7 perf
} else if (chunk.error) {
this.emit('error', chunk.error);
dust.log('Chunk error [' + chunk.error + '] thrown. Ceasing to render this template.', WARN);
this.flush = EMPTY_FUNC;
return;
} else {
return;
}
chunk = chunk.next;
this.head = chunk;
}
this.emit('end');
};
Stream.prototype.emit = function(type, data) {
if (!this.events) {
dust.log('No events to emit', INFO);
return false;
}
var handler = this.events[type];
if (!handler) {
dust.log('Event type [' + type + '] does not exist', WARN);
return false;
}
if (typeof handler === 'function') {
handler(data);
} else if (dust.isArray(handler)) {
var listeners = handler.slice(0);
for (var i = 0, l = listeners.length; i < l; i++) {
listeners[i](data);
}
} else {
dust.log('Event Handler [' + handler + '] is not of a type that is handled by emit', WARN);
}
};
Stream.prototype.on = function(type, callback) {
if (!this.events) {
this.events = {};
}
if (!this.events[type]) {
if(callback) {
this.events[type] = callback;
} else {
dust.log('Callback for type [' + type + '] does not exist. Listener not registered.', WARN);
}
} else if(typeof this.events[type] === 'function') {
this.events[type] = [this.events[type], callback];
} else {
this.events[type].push(callback);
}
return this;
};
Stream.prototype.pipe = function(stream) {
this.on('data', function(data) {
try {
stream.write(data, 'utf8');
} catch (err) {
dust.log(err, ERROR);
}
}).on('end', function() {
try {
return stream.end();
} catch (err) {
dust.log(err, ERROR);
}
}).on('error', function(err) {
stream.error(err);
});
return this;
};
function Chunk(root, next, taps) {
this.root = root;
this.next = next;
this.data = []; //ie7 perf
this.flushable = false;
this.taps = taps;
}
Chunk.prototype.write = function(data) {
var taps = this.taps;
if (taps) {
data = taps.go(data);
}
this.data.push(data);
return this;
};
Chunk.prototype.end = function(data) {
if (data) {
this.write(data);
}
this.flushable = true;
this.root.flush();
return this;
};
Chunk.prototype.map = function(callback) {
var cursor = new Chunk(this.root, this.next, this.taps),
branch = new Chunk(this.root, cursor, this.taps);
this.next = branch;
this.flushable = true;
try {
callback(branch);
} catch(e) {
dust.log(e, ERROR);
branch.setError(e);
}
return cursor;
};
Chunk.prototype.tap = function(tap) {
var taps = this.taps;
if (taps) {
this.taps = taps.push(tap);
} else {
this.taps = new Tap(tap);
}
return this;
};
Chunk.prototype.untap = function() {
this.taps = this.taps.tail;
return this;
};
Chunk.prototype.render = function(body, context) {
return body(this, context);
};
Chunk.prototype.reference = function(elem, context, auto, filters) {
if (typeof elem === 'function') {
// Changed the function calling to use apply with the current context to make sure
// that "this" is wat we expect it to be inside the function
elem = elem.apply(context.current(), [this, context, null, {auto: auto, filters: filters}]);
if (elem instanceof Chunk) {
return elem;
}
}
if (!dust.isEmpty(elem)) {
return this.write(dust.filter(elem, auto, filters));
} else {
return this;
}
};
Chunk.prototype.section = function(elem, context, bodies, params) {
// anonymous functions
if (typeof elem === 'function' && !elem.__dustBody) {
try {
elem = elem.apply(context.current(), [this, context, bodies, params]);
} catch(e) {
dust.log(e, ERROR);
return this.setError(e);
}
// functions that return chunks are assumed to have handled the body and/or have modified the chunk
// use that return value as the current chunk and go to the next method in the chain
if (elem instanceof Chunk) {
return elem;
}
}
var body = bodies.block,
skip = bodies['else'];
// a.k.a Inline parameters in the Dust documentations
if (params) {
context = context.push(params);
}
/*
Dust's default behavior is to enumerate over the array elem, passing each object in the array to the block.
When elem resolves to a value or object instead of an array, Dust sets the current context to the value
and renders the block one time.
*/
//non empty array is truthy, empty array is falsy
if (dust.isArray(elem)) {
if (body) {
var len = elem.length, chunk = this;
if (len > 0) {
// any custom helper can blow up the stack
// and store a flattened context, guard defensively
if(context.stack.head) {
context.stack.head['$len'] = len;
}
for (var i=0; i<len; i++) {
if(context.stack.head) {
context.stack.head['$idx'] = i;
}
chunk = body(chunk, context.push(elem[i], i, len));
}
if(context.stack.head) {
context.stack.head['$idx'] = undefined;
context.stack.head['$len'] = undefined;
}
return chunk;
}
else if (skip) {
return skip(this, context);
}
}
} else if (elem === true) {
// true is truthy but does not change context
if (body) {
return body(this, context);
}
} else if (elem || elem === 0) {
// everything that evaluates to true are truthy ( e.g. Non-empty strings and Empty objects are truthy. )
// zero is truthy
// for anonymous functions that did not returns a chunk, truthiness is evaluated based on the return value
if (body) {
return body(this, context.push(elem));
}
// nonexistent, scalar false value, scalar empty string, null,
// undefined are all falsy
} else if (skip) {
return skip(this, context);
}
dust.log('Not rendering section (#) block in template [' + context.getTemplateName() + '], because above key was not found', DEBUG);
return this;
};
Chunk.prototype.exists = function(elem, context, bodies) {
var body = bodies.block,
skip = bodies['else'];
if (!dust.isEmpty(elem)) {
if (body) {
return body(this, context);
}
} else if (skip) {
return skip(this, context);
}
dust.log('Not rendering exists (?) block in template [' + context.getTemplateName() + '], because above key was not found', DEBUG);
return this;
};
Chunk.prototype.notexists = function(elem, context, bodies) {
var body = bodies.block,
skip = bodies['else'];
if (dust.isEmpty(elem)) {
if (body) {
return body(this, context);
}
} else if (skip) {
return skip(this, context);
}
dust.log('Not rendering not exists (^) block check in template [' + context.getTemplateName() + '], because above key was found', DEBUG);
return this;
};
Chunk.prototype.block = function(elem, context, bodies) {
var body = bodies.block;
if (elem) {
body = elem;
}
if (body) {
return body(this, context);
}
return this;
};
Chunk.prototype.partial = function(elem, context, params) {
var partialContext;
//put the params context second to match what section does. {.} matches the current context without parameters
// start with an empty context
partialContext = dust.makeBase(context.global);
partialContext.blocks = context.blocks;
if (context.stack && context.stack.tail){
// grab the stack(tail) off of the previous context if we have it
partialContext.stack = context.stack.tail;
}
if (params){
//put params on
partialContext = partialContext.push(params);
}
if(typeof elem === 'string') {
partialContext.templateName = elem;
}
//reattach the head
partialContext = partialContext.push(context.stack.head);
var partialChunk;
if (typeof elem === 'function') {
partialChunk = this.capture(elem, partialContext, function(name, chunk) {
partialContext.templateName = partialContext.templateName || name;
dust.load(name, chunk, partialContext).end();
});
} else {
partialChunk = dust.load(elem, this, partialContext);
}
return partialChunk;
};
Chunk.prototype.helper = function(name, context, bodies, params) {
var chunk = this;
// handle invalid helpers, similar to invalid filters
if(dust.helpers[name]) {
try {
return dust.helpers[name](chunk, context, bodies, params);
} catch(e) {
dust.log('Error in ' + name + ' helper: ' + e, ERROR);
return chunk.setError(e);
}
} else {
dust.log('Invalid helper [' + name + ']', WARN);
return chunk;
}
};
Chunk.prototype.capture = function(body, context, callback) {
return this.map(function(chunk) {
var stub = new Stub(function(err, out) {
if (err) {
chunk.setError(err);
} else {
callback(out, chunk);
}
});
body(stub.head, context).end();
});
};
Chunk.prototype.setError = function(err) {
this.error = err;
this.root.flush();
return this;
};
// Chunk aliases
for(var f in Chunk.prototype) {
if(dust._aliases[f]) {
Chunk.prototype[dust._aliases[f]] = Chunk.prototype[f];
}
}
function Tap(head, tail) {
this.head = head;
this.tail = tail;
}
Tap.prototype.push = function(tap) {
return new Tap(tap, this);
};
Tap.prototype.go = function(value) {
var tap = this;
while(tap) {
value = tap.head(value);
tap = tap.tail;
}
return value;
};
var HCHARS = /[&<>"']/,
AMP = /&/g,
LT = /</g,
GT = />/g,
QUOT = /\"/g,
SQUOT = /\'/g;
dust.escapeHtml = function(s) {
if (typeof s === 'string') {
if (!HCHARS.test(s)) {
return s;
}
return s.replace(AMP,'&').replace(LT,'<').replace(GT,'>').replace(QUOT,'"').replace(SQUOT, ''');
}
return s;
};
var BS = /\\/g,
FS = /\//g,
CR = /\r/g,
LS = /\u2028/g,
PS = /\u2029/g,
NL = /\n/g,
LF = /\f/g,
SQ = /'/g,
DQ = /"/g,
TB = /\t/g;
dust.escapeJs = function(s) {
if (typeof s === 'string') {
return s
.replace(BS, '\\\\')
.replace(FS, '\\/')
.replace(DQ, '\\"')
.replace(SQ, '\\\'')
.replace(CR, '\\r')
.replace(LS, '\\u2028')
.replace(PS, '\\u2029')
.replace(NL, '\\n')
.replace(LF, '\\f')
.replace(TB, '\\t');
}
return s;
};
if (typeof exports === 'object') {
module.exports = dust;
} else {
root.dust = dust;
}
})((function(){return this;})());