#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?s)/\*.*?\*/|//[^\r\n]*"
Local $sString = "/*! dustjs-linkedin - v2.7.2" & @CRLF & _
"* http://dustjs.com/" & @CRLF & _
"* Copyright (c) 2015 Aleksander Williams; Released under the MIT License */" & @CRLF & _
"(function (root, factory) {" & @CRLF & _
" if (typeof define === 'function' && define.amd && define.amd.dust === true) {" & @CRLF & _
" define('dust.core', [], factory);" & @CRLF & _
" } else if (typeof exports === 'object') {" & @CRLF & _
" module.exports = factory();" & @CRLF & _
" } else {" & @CRLF & _
" root.dust = factory();" & @CRLF & _
" }" & @CRLF & _
"}(this, function() {" & @CRLF & _
" var dust = {" & @CRLF & _
" "version": "2.7.2"" & @CRLF & _
" }," & @CRLF & _
" NONE = 'NONE', ERROR = 'ERROR', WARN = 'WARN', INFO = 'INFO', DEBUG = 'DEBUG'," & @CRLF & _
" EMPTY_FUNC = function() {};" & @CRLF & _
"" & @CRLF & _
" dust.config = {" & @CRLF & _
" whitespace: false," & @CRLF & _
" amd: false," & @CRLF & _
" cjs: false," & @CRLF & _
" cache: true" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" // Directive aliases to minify code" & @CRLF & _
" dust._aliases = {" & @CRLF & _
" "write": "w"," & @CRLF & _
" "end": "e"," & @CRLF & _
" "map": "m"," & @CRLF & _
" "render": "r"," & @CRLF & _
" "reference": "f"," & @CRLF & _
" "section": "s"," & @CRLF & _
" "exists": "x"," & @CRLF & _
" "notexists": "nx"," & @CRLF & _
" "block": "b"," & @CRLF & _
" "partial": "p"," & @CRLF & _
" "helper": "h"" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" (function initLogging() {" & @CRLF & _
" /*global process, console*/" & @CRLF & _
" var loggingLevels = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, NONE: 4 }," & @CRLF & _
" consoleLog," & @CRLF & _
" log;" & @CRLF & _
"" & @CRLF & _
" if (typeof console !== 'undefined' && console.log) {" & @CRLF & _
" consoleLog = console.log;" & @CRLF & _
" if(typeof consoleLog === 'function') {" & @CRLF & _
" log = function() {" & @CRLF & _
" consoleLog.apply(console, arguments);" & @CRLF & _
" };" & @CRLF & _
" } else {" & @CRLF & _
" log = function() {" & @CRLF & _
" consoleLog(Array.prototype.slice.apply(arguments).join(' '));" & @CRLF & _
" };" & @CRLF & _
" }" & @CRLF & _
" } else {" & @CRLF & _
" log = EMPTY_FUNC;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Filters messages based on `dust.debugLevel`." & @CRLF & _
" * This default implementation will print to the console if it exists." & @CRLF & _
" * @param {String|Error} message the message to print/throw" & @CRLF & _
" * @param {String} type the severity of the message(ERROR, WARN, INFO, or DEBUG)" & @CRLF & _
" * @public" & @CRLF & _
" */" & @CRLF & _
" dust.log = function(message, type) {" & @CRLF & _
" type = type || INFO;" & @CRLF & _
" if (loggingLevels[type] >= loggingLevels[dust.debugLevel]) {" & @CRLF & _
" log('[DUST:' + type + ']', message);" & @CRLF & _
" }" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" dust.debugLevel = NONE;" & @CRLF & _
" if(typeof process !== 'undefined' && process.env && /\bdust\b/.test(process.env.DEBUG)) {" & @CRLF & _
" dust.debugLevel = DEBUG;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" }());" & @CRLF & _
"" & @CRLF & _
" dust.helpers = {};" & @CRLF & _
"" & @CRLF & _
" dust.cache = {};" & @CRLF & _
"" & @CRLF & _
" dust.register = function(name, tmpl) {" & @CRLF & _
" if (!name) {" & @CRLF & _
" return;" & @CRLF & _
" }" & @CRLF & _
" tmpl.templateName = name;" & @CRLF & _
" if (dust.config.cache !== false) {" & @CRLF & _
" dust.cache[name] = tmpl;" & @CRLF & _
" }" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" dust.render = function(nameOrTemplate, context, callback) {" & @CRLF & _
" var chunk = new Stub(callback).head;" & @CRLF & _
" try {" & @CRLF & _
" load(nameOrTemplate, chunk, context).end();" & @CRLF & _
" } catch (err) {" & @CRLF & _
" chunk.setError(err);" & @CRLF & _
" }" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" dust.stream = function(nameOrTemplate, context) {" & @CRLF & _
" var stream = new Stream()," & @CRLF & _
" chunk = stream.head;" & @CRLF & _
" dust.nextTick(function() {" & @CRLF & _
" try {" & @CRLF & _
" load(nameOrTemplate, chunk, context).end();" & @CRLF & _
" } catch (err) {" & @CRLF & _
" chunk.setError(err);" & @CRLF & _
" }" & @CRLF & _
" });" & @CRLF & _
" return stream;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Extracts a template function (body_0) from whatever is passed." & @CRLF & _
" * @param nameOrTemplate {*} Could be:" & @CRLF & _
" * - the name of a template to load from cache" & @CRLF & _
" * - a CommonJS-compiled template (a function with a `template` property)" & @CRLF & _
" * - a template function" & @CRLF & _
" * @param loadFromCache {Boolean} if false, don't look in the cache" & @CRLF & _
" * @return {Function} a template function, if found" & @CRLF & _
" */" & @CRLF & _
" function getTemplate(nameOrTemplate, loadFromCache/*=true*/) {" & @CRLF & _
" if(!nameOrTemplate) {" & @CRLF & _
" return;" & @CRLF & _
" }" & @CRLF & _
" if(typeof nameOrTemplate === 'function' && nameOrTemplate.template) {" & @CRLF & _
" // Sugar away CommonJS module templates" & @CRLF & _
" return nameOrTemplate.template;" & @CRLF & _
" }" & @CRLF & _
" if(dust.isTemplateFn(nameOrTemplate)) {" & @CRLF & _
" // Template functions passed directly" & @CRLF & _
" return nameOrTemplate;" & @CRLF & _
" }" & @CRLF & _
" if(loadFromCache !== false) {" & @CRLF & _
" // Try loading a template with this name from cache" & @CRLF & _
" return dust.cache[nameOrTemplate];" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" function load(nameOrTemplate, chunk, context) {" & @CRLF & _
" if(!nameOrTemplate) {" & @CRLF & _
" return chunk.setError(new Error('No template or template name provided to render'));" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" var template = getTemplate(nameOrTemplate, dust.config.cache);" & @CRLF & _
"" & @CRLF & _
" if (template) {" & @CRLF & _
" return template(chunk, Context.wrap(context, template.templateName));" & @CRLF & _
" } else {" & @CRLF & _
" if (dust.onLoad) {" & @CRLF & _
" return chunk.map(function(chunk) {" & @CRLF & _
" // Alias just so it's easier to read that this would always be a name" & @CRLF & _
" var name = nameOrTemplate;" & @CRLF & _
" // Three possible scenarios for a successful callback:" & @CRLF & _
" // - `require(nameOrTemplate)(dust); cb()`" & @CRLF & _
" // - `src = readFile('src.dust'); cb(null, src)`" & @CRLF & _
" // - `compiledTemplate = require(nameOrTemplate)(dust); cb(null, compiledTemplate)`" & @CRLF & _
" function done(err, srcOrTemplate) {" & @CRLF & _
" var template;" & @CRLF & _
" if (err) {" & @CRLF & _
" return chunk.setError(err);" & @CRLF & _
" }" & @CRLF & _
" // Prefer a template that is passed via callback over the cached version." & @CRLF & _
" template = getTemplate(srcOrTemplate, false) || getTemplate(name, dust.config.cache);" & @CRLF & _
" if (!template) {" & @CRLF & _
" // It's a template string, compile it and register under `name`" & @CRLF & _
" if(dust.compile) {" & @CRLF & _
" template = dust.loadSource(dust.compile(srcOrTemplate, name));" & @CRLF & _
" } else {" & @CRLF & _
" return chunk.setError(new Error('Dust compiler not available'));" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" template(chunk, Context.wrap(context, template.templateName)).end();" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" if(dust.onLoad.length === 3) {" & @CRLF & _
" dust.onLoad(name, context.options, done);" & @CRLF & _
" } else {" & @CRLF & _
" dust.onLoad(name, done);" & @CRLF & _
" }" & @CRLF & _
" });" & @CRLF & _
" }" & @CRLF & _
" return chunk.setError(new Error('Template Not Found: ' + nameOrTemplate));" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" dust.loadSource = function(source) {" & @CRLF & _
" /*jshint evil:true*/" & @CRLF & _
" return eval(source);" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" if (Array.isArray) {" & @CRLF & _
" dust.isArray = Array.isArray;" & @CRLF & _
" } else {" & @CRLF & _
" dust.isArray = function(arr) {" & @CRLF & _
" return Object.prototype.toString.call(arr) === '[object Array]';" & @CRLF & _
" };" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" dust.nextTick = (function() {" & @CRLF & _
" return function(callback) {" & @CRLF & _
" setTimeout(callback, 0);" & @CRLF & _
" };" & @CRLF & _
" })();" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Dust has its own rules for what is "empty"-- which is not the same as falsy." & @CRLF & _
" * Empty arrays, null, and undefined are empty" & @CRLF & _
" */" & @CRLF & _
" dust.isEmpty = function(value) {" & @CRLF & _
" if (value === 0) {" & @CRLF & _
" return false;" & @CRLF & _
" }" & @CRLF & _
" if (dust.isArray(value) && !value.length) {" & @CRLF & _
" return true;" & @CRLF & _
" }" & @CRLF & _
" return !value;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" dust.isEmptyObject = function(obj) {" & @CRLF & _
" var key;" & @CRLF & _
" if (obj === null) {" & @CRLF & _
" return false;" & @CRLF & _
" }" & @CRLF & _
" if (obj === undefined) {" & @CRLF & _
" return false;" & @CRLF & _
" }" & @CRLF & _
" if (obj.length > 0) {" & @CRLF & _
" return false;" & @CRLF & _
" }" & @CRLF & _
" for (key in obj) {" & @CRLF & _
" if (Object.prototype.hasOwnProperty.call(obj, key)) {" & @CRLF & _
" return false;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" return true;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" dust.isTemplateFn = function(elem) {" & @CRLF & _
" return typeof elem === 'function' &&" & @CRLF & _
" elem.__dustBody;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Decide somewhat-naively if something is a Thenable." & @CRLF & _
" * @param elem {*} object to inspect" & @CRLF & _
" * @return {Boolean} is `elem` a Thenable?" & @CRLF & _
" */" & @CRLF & _
" dust.isThenable = function(elem) {" & @CRLF & _
" return elem &&" & @CRLF & _
" typeof elem === 'object' &&" & @CRLF & _
" typeof elem.then === 'function';" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Decide very naively if something is a Stream." & @CRLF & _
" * @param elem {*} object to inspect" & @CRLF & _
" * @return {Boolean} is `elem` a Stream?" & @CRLF & _
" */" & @CRLF & _
" dust.isStreamable = function(elem) {" & @CRLF & _
" return elem &&" & @CRLF & _
" typeof elem.on === 'function' &&" & @CRLF & _
" typeof elem.pipe === 'function';" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" // apply the filter chain and return the output string" & @CRLF & _
" dust.filter = function(string, auto, filters, context) {" & @CRLF & _
" var i, len, name, filter;" & @CRLF & _
" if (filters) {" & @CRLF & _
" for (i = 0, len = filters.length; i < len; i++) {" & @CRLF & _
" name = filters[i];" & @CRLF & _
" if (!name.length) {" & @CRLF & _
" continue;" & @CRLF & _
" }" & @CRLF & _
" filter = dust.filters[name];" & @CRLF & _
" if (name === 's') {" & @CRLF & _
" auto = null;" & @CRLF & _
" } else if (typeof filter === 'function') {" & @CRLF & _
" string = filter(string, context);" & @CRLF & _
" } else {" & @CRLF & _
" dust.log('Invalid filter `' + name + '`', WARN);" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" // by default always apply the h filter, unless asked to unescape with |s" & @CRLF & _
" if (auto) {" & @CRLF & _
" string = dust.filters[auto](string, context);" & @CRLF & _
" }" & @CRLF & _
" return string;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" dust.filters = {" & @CRLF & _
" h: function(value) { return dust.escapeHtml(value); }," & @CRLF & _
" j: function(value) { return dust.escapeJs(value); }," & @CRLF & _
" u: encodeURI," & @CRLF & _
" uc: encodeURIComponent," & @CRLF & _
" js: function(value) { return dust.escapeJSON(value); }," & @CRLF & _
" jp: function(value) {" & @CRLF & _
" if (!JSON) {dust.log('JSON is undefined; could not parse `' + value + '`', WARN);" & @CRLF & _
" return value;" & @CRLF & _
" } else {" & @CRLF & _
" return JSON.parse(value);" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" function Context(stack, global, options, blocks, templateName) {" & @CRLF & _
" if(stack !== undefined && !(stack instanceof Stack)) {" & @CRLF & _
" stack = new Stack(stack);" & @CRLF & _
" }" & @CRLF & _
" this.stack = stack;" & @CRLF & _
" this.global = global;" & @CRLF & _
" this.options = options;" & @CRLF & _
" this.blocks = blocks;" & @CRLF & _
" this.templateName = templateName;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" dust.makeBase = dust.context = function(global, options) {" & @CRLF & _
" return new Context(undefined, global, options);" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Factory function that creates a closure scope around a Thenable-callback." & @CRLF & _
" * Returns a function that can be passed to a Thenable that will resume a" & @CRLF & _
" * Context lookup once the Thenable resolves with new data, adding that new" & @CRLF & _
" * data to the lookup stack." & @CRLF & _
" */" & @CRLF & _
" function getWithResolvedData(ctx, cur, down) {" & @CRLF & _
" return function(data) {" & @CRLF & _
" return ctx.push(data)._get(cur, down);" & @CRLF & _
" };" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" Context.wrap = function(context, name) {" & @CRLF & _
" if (context instanceof Context) {" & @CRLF & _
" return context;" & @CRLF & _
" }" & @CRLF & _
" return new Context(context, {}, {}, null, name);" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Public API for getting a value from the context." & @CRLF & _
" * @method get" & @CRLF & _
" * @param {string|array} path The path to the value. Supported formats are:" & @CRLF & _
" * 'key'" & @CRLF & _
" * 'path.to.key'" & @CRLF & _
" * '.path.to.key'" & @CRLF & _
" * ['path', 'to', 'key']" & @CRLF & _
" * ['key']" & @CRLF & _
" * @param {boolean} [cur=false] Boolean which determines if the search should be limited to the" & @CRLF & _
" * current context (true), or if get should search in parent contexts as well (false)." & @CRLF & _
" * @public" & @CRLF & _
" * @returns {string|object}" & @CRLF & _
" */" & @CRLF & _
" Context.prototype.get = function(path, cur) {" & @CRLF & _
" if (typeof path === 'string') {" & @CRLF & _
" if (path[0] === '.') {" & @CRLF & _
" cur = true;" & @CRLF & _
" path = path.substr(1);" & @CRLF & _
" }" & @CRLF & _
" path = path.split('.');" & @CRLF & _
" }" & @CRLF & _
" return this._get(cur, path);" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Get a value from the context" & @CRLF & _
" * @method _get" & @CRLF & _
" * @param {boolean} cur Get only from the current context" & @CRLF & _
" * @param {array} down An array of each step in the path" & @CRLF & _
" * @private" & @CRLF & _
" * @return {string | object}" & @CRLF & _
" */" & @CRLF & _
" Context.prototype._get = function(cur, down) {" & @CRLF & _
" var ctx = this.stack || {}," & @CRLF & _
" i = 1," & @CRLF & _
" value, first, len, ctxThis, fn;" & @CRLF & _
"" & @CRLF & _
" first = down[0];" & @CRLF & _
" len = down.length;" & @CRLF & _
"" & @CRLF & _
" if (cur && len === 0) {" & @CRLF & _
" ctxThis = ctx;" & @CRLF & _
" ctx = ctx.head;" & @CRLF & _
" } else {" & @CRLF & _
" if (!cur) {" & @CRLF & _
" // Search up the stack for the first value" & @CRLF & _
" while (ctx) {" & @CRLF & _
" if (ctx.isObject) {" & @CRLF & _
" ctxThis = ctx.head;" & @CRLF & _
" value = ctx.head[first];" & @CRLF & _
" if (value !== undefined) {" & @CRLF & _
" break;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" ctx = ctx.tail;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" // Try looking in the global context if we haven't found anything yet" & @CRLF & _
" if (value !== undefined) {" & @CRLF & _
" ctx = value;" & @CRLF & _
" } else {" & @CRLF & _
" ctx = this.global && this.global[first];" & @CRLF & _
" }" & @CRLF & _
" } else if (ctx) {" & @CRLF & _
" // if scope is limited by a leading dot, don't search up the tree" & @CRLF & _
" if(ctx.head) {" & @CRLF & _
" ctx = ctx.head[first];" & @CRLF & _
" } else {" & @CRLF & _
" // context's head is empty, value we are searching for is not defined" & @CRLF & _
" ctx = undefined;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" while (ctx && i < len) {" & @CRLF & _
" if (dust.isThenable(ctx)) {" & @CRLF & _
" // Bail early by returning a Thenable for the remainder of the search tree" & @CRLF & _
" return ctx.then(getWithResolvedData(this, cur, down.slice(i)));" & @CRLF & _
" }" & @CRLF & _
" ctxThis = ctx;" & @CRLF & _
" ctx = ctx[down[i]];" & @CRLF & _
" i++;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" if (typeof ctx === 'function') {" & @CRLF & _
" fn = function() {" & @CRLF & _
" try {" & @CRLF & _
" return ctx.apply(ctxThis, arguments);" & @CRLF & _
" } catch (err) {" & @CRLF & _
" dust.log(err, ERROR);" & @CRLF & _
" throw err;" & @CRLF & _
" }" & @CRLF & _
" };" & @CRLF & _
" fn.__dustBody = !!ctx.__dustBody;" & @CRLF & _
" return fn;" & @CRLF & _
" } else {" & @CRLF & _
" if (ctx === undefined) {" & @CRLF & _
" dust.log('Cannot find reference `{' + down.join('.') + '}` in template `' + this.getTemplateName() + '`', INFO);" & @CRLF & _
" }" & @CRLF & _
" return ctx;" & @CRLF & _
" }" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Context.prototype.getPath = function(cur, down) {" & @CRLF & _
" return this._get(cur, down);" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Context.prototype.push = function(head, idx, len) {" & @CRLF & _
" if(head === undefined) {" & @CRLF & _
" dust.log("Not pushing an undefined variable onto the context", INFO);" & @CRLF & _
" return this;" & @CRLF & _
" }" & @CRLF & _
" return this.rebase(new Stack(head, this.stack, idx, len));" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Context.prototype.pop = function() {" & @CRLF & _
" var head = this.current();" & @CRLF & _
" this.stack = this.stack && this.stack.tail;" & @CRLF & _
" return head;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Context.prototype.rebase = function(head) {" & @CRLF & _
" return new Context(head, this.global, this.options, this.blocks, this.getTemplateName());" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Context.prototype.clone = function() {" & @CRLF & _
" var context = this.rebase();" & @CRLF & _
" context.stack = this.stack;" & @CRLF & _
" return context;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Context.prototype.current = function() {" & @CRLF & _
" return this.stack && this.stack.head;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Context.prototype.getBlock = function(key) {" & @CRLF & _
" var blocks, len, fn;" & @CRLF & _
"" & @CRLF & _
" if (typeof key === 'function') {" & @CRLF & _
" key = key(new Chunk(), this).data.join('');" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" blocks = this.blocks;" & @CRLF & _
"" & @CRLF & _
" if (!blocks) {" & @CRLF & _
" dust.log('No blocks for context `' + key + '` in template `' + this.getTemplateName() + '`', DEBUG);" & @CRLF & _
" return false;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" len = blocks.length;" & @CRLF & _
" while (len--) {" & @CRLF & _
" fn = blocks[len][key];" & @CRLF & _
" if (fn) {" & @CRLF & _
" return fn;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" dust.log('Malformed template `' + this.getTemplateName() + '` was missing one or more blocks.');" & @CRLF & _
" return false;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Context.prototype.shiftBlocks = function(locals) {" & @CRLF & _
" var blocks = this.blocks," & @CRLF & _
" newBlocks;" & @CRLF & _
"" & @CRLF & _
" if (locals) {" & @CRLF & _
" if (!blocks) {" & @CRLF & _
" newBlocks = [locals];" & @CRLF & _
" } else {" & @CRLF & _
" newBlocks = blocks.concat([locals]);" & @CRLF & _
" }" & @CRLF & _
" return new Context(this.stack, this.global, this.options, newBlocks, this.getTemplateName());" & @CRLF & _
" }" & @CRLF & _
" return this;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Context.prototype.resolve = function(body) {" & @CRLF & _
" var chunk;" & @CRLF & _
"" & @CRLF & _
" if(typeof body !== 'function') {" & @CRLF & _
" return body;" & @CRLF & _
" }" & @CRLF & _
" chunk = new Chunk().render(body, this);" & @CRLF & _
" if(chunk instanceof Chunk) {" & @CRLF & _
" return chunk.data.join(''); // ie7 perf" & @CRLF & _
" }" & @CRLF & _
" return chunk;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Context.prototype.getTemplateName = function() {" & @CRLF & _
" return this.templateName;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" function Stack(head, tail, idx, len) {" & @CRLF & _
" this.tail = tail;" & @CRLF & _
" this.isObject = head && typeof head === 'object';" & @CRLF & _
" this.head = head;" & @CRLF & _
" this.index = idx;" & @CRLF & _
" this.of = len;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" function Stub(callback) {" & @CRLF & _
" this.head = new Chunk(this);" & @CRLF & _
" this.callback = callback;" & @CRLF & _
" this.out = '';" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" Stub.prototype.flush = function() {" & @CRLF & _
" var chunk = this.head;" & @CRLF & _
"" & @CRLF & _
" while (chunk) {" & @CRLF & _
" if (chunk.flushable) {" & @CRLF & _
" this.out += chunk.data.join(''); //ie7 perf" & @CRLF & _
" } else if (chunk.error) {" & @CRLF & _
" this.callback(chunk.error);" & @CRLF & _
" dust.log('Rendering failed with error `' + chunk.error + '`', ERROR);" & @CRLF & _
" this.flush = EMPTY_FUNC;" & @CRLF & _
" return;" & @CRLF & _
" } else {" & @CRLF & _
" return;" & @CRLF & _
" }" & @CRLF & _
" chunk = chunk.next;" & @CRLF & _
" this.head = chunk;" & @CRLF & _
" }" & @CRLF & _
" this.callback(null, this.out);" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Creates an interface sort of like a Streams2 ReadableStream." & @CRLF & _
" */" & @CRLF & _
" function Stream() {" & @CRLF & _
" this.head = new Chunk(this);" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" Stream.prototype.flush = function() {" & @CRLF & _
" var chunk = this.head;" & @CRLF & _
"" & @CRLF & _
" while(chunk) {" & @CRLF & _
" if (chunk.flushable) {" & @CRLF & _
" this.emit('data', chunk.data.join('')); //ie7 perf" & @CRLF & _
" } else if (chunk.error) {" & @CRLF & _
" this.emit('error', chunk.error);" & @CRLF & _
" this.emit('end');" & @CRLF & _
" dust.log('Streaming failed with error `' + chunk.error + '`', ERROR);" & @CRLF & _
" this.flush = EMPTY_FUNC;" & @CRLF & _
" return;" & @CRLF & _
" } else {" & @CRLF & _
" return;" & @CRLF & _
" }" & @CRLF & _
" chunk = chunk.next;" & @CRLF & _
" this.head = chunk;" & @CRLF & _
" }" & @CRLF & _
" this.emit('end');" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Executes listeners for `type` by passing data. Note that this is different from a" & @CRLF & _
" * Node stream, which can pass an arbitrary number of arguments" & @CRLF & _
" * @return `true` if event had listeners, `false` otherwise" & @CRLF & _
" */" & @CRLF & _
" Stream.prototype.emit = function(type, data) {" & @CRLF & _
" var events = this.events || {}," & @CRLF & _
" handlers = events[type] || []," & @CRLF & _
" i, l;" & @CRLF & _
"" & @CRLF & _
" if (!handlers.length) {" & @CRLF & _
" dust.log('Stream broadcasting, but no listeners for `' + type + '`', DEBUG);" & @CRLF & _
" return false;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" handlers = handlers.slice(0);" & @CRLF & _
" for (i = 0, l = handlers.length; i < l; i++) {" & @CRLF & _
" handlers[i](data);" & @CRLF & _
" }" & @CRLF & _
" return true;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Stream.prototype.on = function(type, callback) {" & @CRLF & _
" var events = this.events = this.events || {}," & @CRLF & _
" handlers = events[type] = events[type] || [];" & @CRLF & _
"" & @CRLF & _
" if(typeof callback !== 'function') {" & @CRLF & _
" dust.log('No callback function provided for `' + type + '` event listener', WARN);" & @CRLF & _
" } else {" & @CRLF & _
" handlers.push(callback);" & @CRLF & _
" }" & @CRLF & _
" return this;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Pipes to a WritableStream. Note that backpressure isn't implemented," & @CRLF & _
" * so we just write as fast as we can." & @CRLF & _
" * @param stream {WritableStream}" & @CRLF & _
" * @return self" & @CRLF & _
" */" & @CRLF & _
" Stream.prototype.pipe = function(stream) {" & @CRLF & _
" if(typeof stream.write !== 'function' ||" & @CRLF & _
" typeof stream.end !== 'function') {" & @CRLF & _
" dust.log('Incompatible stream passed to `pipe`', WARN);" & @CRLF & _
" return this;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" var destEnded = false;" & @CRLF & _
"" & @CRLF & _
" if(typeof stream.emit === 'function') {" & @CRLF & _
" stream.emit('pipe', this);" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" if(typeof stream.on === 'function') {" & @CRLF & _
" stream.on('error', function() {" & @CRLF & _
" destEnded = true;" & @CRLF & _
" });" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" return this" & @CRLF & _
" .on('data', function(data) {" & @CRLF & _
" if(destEnded) {" & @CRLF & _
" return;" & @CRLF & _
" }" & @CRLF & _
" try {" & @CRLF & _
" stream.write(data, 'utf8');" & @CRLF & _
" } catch (err) {" & @CRLF & _
" dust.log(err, ERROR);" & @CRLF & _
" }" & @CRLF & _
" })" & @CRLF & _
" .on('end', function() {" & @CRLF & _
" if(destEnded) {" & @CRLF & _
" return;" & @CRLF & _
" }" & @CRLF & _
" try {" & @CRLF & _
" stream.end();" & @CRLF & _
" destEnded = true;" & @CRLF & _
" } catch (err) {" & @CRLF & _
" dust.log(err, ERROR);" & @CRLF & _
" }" & @CRLF & _
" });" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" function Chunk(root, next, taps) {" & @CRLF & _
" this.root = root;" & @CRLF & _
" this.next = next;" & @CRLF & _
" this.data = []; //ie7 perf" & @CRLF & _
" this.flushable = false;" & @CRLF & _
" this.taps = taps;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.write = function(data) {" & @CRLF & _
" var taps = this.taps;" & @CRLF & _
"" & @CRLF & _
" if (taps) {" & @CRLF & _
" data = taps.go(data);" & @CRLF & _
" }" & @CRLF & _
" this.data.push(data);" & @CRLF & _
" return this;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.end = function(data) {" & @CRLF & _
" if (data) {" & @CRLF & _
" this.write(data);" & @CRLF & _
" }" & @CRLF & _
" this.flushable = true;" & @CRLF & _
" this.root.flush();" & @CRLF & _
" return this;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.map = function(callback) {" & @CRLF & _
" var cursor = new Chunk(this.root, this.next, this.taps)," & @CRLF & _
" branch = new Chunk(this.root, cursor, this.taps);" & @CRLF & _
"" & @CRLF & _
" this.next = branch;" & @CRLF & _
" this.flushable = true;" & @CRLF & _
" try {" & @CRLF & _
" callback(branch);" & @CRLF & _
" } catch(err) {" & @CRLF & _
" dust.log(err, ERROR);" & @CRLF & _
" branch.setError(err);" & @CRLF & _
" }" & @CRLF & _
" return cursor;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.tap = function(tap) {" & @CRLF & _
" var taps = this.taps;" & @CRLF & _
"" & @CRLF & _
" if (taps) {" & @CRLF & _
" this.taps = taps.push(tap);" & @CRLF & _
" } else {" & @CRLF & _
" this.taps = new Tap(tap);" & @CRLF & _
" }" & @CRLF & _
" return this;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.untap = function() {" & @CRLF & _
" this.taps = this.taps.tail;" & @CRLF & _
" return this;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.render = function(body, context) {" & @CRLF & _
" return body(this, context);" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.reference = function(elem, context, auto, filters) {" & @CRLF & _
" if (typeof elem === 'function') {" & @CRLF & _
" elem = elem.apply(context.current(), [this, context, null, {auto: auto, filters: filters}]);" & @CRLF & _
" if (elem instanceof Chunk) {" & @CRLF & _
" return elem;" & @CRLF & _
" } else {" & @CRLF & _
" return this.reference(elem, context, auto, filters);" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" if (dust.isThenable(elem)) {" & @CRLF & _
" return this.await(elem, context, null, auto, filters);" & @CRLF & _
" } else if (dust.isStreamable(elem)) {" & @CRLF & _
" return this.stream(elem, context, null, auto, filters);" & @CRLF & _
" } else if (!dust.isEmpty(elem)) {" & @CRLF & _
" return this.write(dust.filter(elem, auto, filters, context));" & @CRLF & _
" } else {" & @CRLF & _
" return this;" & @CRLF & _
" }" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.section = function(elem, context, bodies, params) {" & @CRLF & _
" var body = bodies.block," & @CRLF & _
" skip = bodies['else']," & @CRLF & _
" chunk = this," & @CRLF & _
" i, len, head;" & @CRLF & _
"" & @CRLF & _
" if (typeof elem === 'function' && !dust.isTemplateFn(elem)) {" & @CRLF & _
" try {" & @CRLF & _
" elem = elem.apply(context.current(), [this, context, bodies, params]);" & @CRLF & _
" } catch(err) {" & @CRLF & _
" dust.log(err, ERROR);" & @CRLF & _
" return this.setError(err);" & @CRLF & _
" }" & @CRLF & _
" // Functions that return chunks are assumed to have handled the chunk manually." & @CRLF & _
" // Make that chunk the current one and go to the next method in the chain." & @CRLF & _
" if (elem instanceof Chunk) {" & @CRLF & _
" return elem;" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" if (dust.isEmptyObject(bodies)) {" & @CRLF & _
" // No bodies to render, and we've already invoked any function that was available in" & @CRLF & _
" // hopes of returning a Chunk." & @CRLF & _
" return chunk;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" if (!dust.isEmptyObject(params)) {" & @CRLF & _
" context = context.push(params);" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" /*" & @CRLF & _
" Dust's default behavior is to enumerate over the array elem, passing each object in the array to the block." & @CRLF & _
" When elem resolves to a value or object instead of an array, Dust sets the current context to the value" & @CRLF & _
" and renders the block one time." & @CRLF & _
" */" & @CRLF & _
" if (dust.isArray(elem)) {" & @CRLF & _
" if (body) {" & @CRLF & _
" len = elem.length;" & @CRLF & _
" if (len > 0) {" & @CRLF & _
" head = context.stack && context.stack.head || {};" & @CRLF & _
" head.$len = len;" & @CRLF & _
" for (i = 0; i < len; i++) {" & @CRLF & _
" head.$idx = i;" & @CRLF & _
" chunk = body(chunk, context.push(elem[i], i, len));" & @CRLF & _
" }" & @CRLF & _
" head.$idx = undefined;" & @CRLF & _
" head.$len = undefined;" & @CRLF & _
" return chunk;" & @CRLF & _
" } else if (skip) {" & @CRLF & _
" return skip(this, context);" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" } else if (dust.isThenable(elem)) {" & @CRLF & _
" return this.await(elem, context, bodies);" & @CRLF & _
" } else if (dust.isStreamable(elem)) {" & @CRLF & _
" return this.stream(elem, context, bodies);" & @CRLF & _
" } else if (elem === true) {" & @CRLF & _
" // true is truthy but does not change context" & @CRLF & _
" if (body) {" & @CRLF & _
" return body(this, context);" & @CRLF & _
" }" & @CRLF & _
" } else if (elem || elem === 0) {" & @CRLF & _
" // everything that evaluates to true are truthy ( e.g. Non-empty strings and Empty objects are truthy. )" & @CRLF & _
" // zero is truthy" & @CRLF & _
" // for anonymous functions that did not returns a chunk, truthiness is evaluated based on the return value" & @CRLF & _
" if (body) {" & @CRLF & _
" return body(this, context.push(elem));" & @CRLF & _
" }" & @CRLF & _
" // nonexistent, scalar false value, scalar empty string, null," & @CRLF & _
" // undefined are all falsy" & @CRLF & _
" } else if (skip) {" & @CRLF & _
" return skip(this, context);" & @CRLF & _
" }" & @CRLF & _
" dust.log('Section without corresponding key in template `' + context.getTemplateName() + '`', DEBUG);" & @CRLF & _
" return this;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.exists = function(elem, context, bodies) {" & @CRLF & _
" var body = bodies.block," & @CRLF & _
" skip = bodies['else'];" & @CRLF & _
"" & @CRLF & _
" if (!dust.isEmpty(elem)) {" & @CRLF & _
" if (body) {" & @CRLF & _
" return body(this, context);" & @CRLF & _
" }" & @CRLF & _
" dust.log('No block for exists check in template `' + context.getTemplateName() + '`', DEBUG);" & @CRLF & _
" } else if (skip) {" & @CRLF & _
" return skip(this, context);" & @CRLF & _
" }" & @CRLF & _
" return this;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.notexists = function(elem, context, bodies) {" & @CRLF & _
" var body = bodies.block," & @CRLF & _
" skip = bodies['else'];" & @CRLF & _
"" & @CRLF & _
" if (dust.isEmpty(elem)) {" & @CRLF & _
" if (body) {" & @CRLF & _
" return body(this, context);" & @CRLF & _
" }" & @CRLF & _
" dust.log('No block for not-exists check in template `' + context.getTemplateName() + '`', DEBUG);" & @CRLF & _
" } else if (skip) {" & @CRLF & _
" return skip(this, context);" & @CRLF & _
" }" & @CRLF & _
" return this;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.block = function(elem, context, bodies) {" & @CRLF & _
" var body = elem || bodies.block;" & @CRLF & _
"" & @CRLF & _
" if (body) {" & @CRLF & _
" return body(this, context);" & @CRLF & _
" }" & @CRLF & _
" return this;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.partial = function(elem, context, partialContext, params) {" & @CRLF & _
" var head;" & @CRLF & _
"" & @CRLF & _
" if(params === undefined) {" & @CRLF & _
" // Compatibility for < 2.7.0 where `partialContext` did not exist" & @CRLF & _
" params = partialContext;" & @CRLF & _
" partialContext = context;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" if (!dust.isEmptyObject(params)) {" & @CRLF & _
" partialContext = partialContext.clone();" & @CRLF & _
" head = partialContext.pop();" & @CRLF & _
" partialContext = partialContext.push(params)" & @CRLF & _
" .push(head);" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" if (dust.isTemplateFn(elem)) {" & @CRLF & _
" // The eventual result of evaluating `elem` is a partial name" & @CRLF & _
" // Load the partial after getting its name and end the async chunk" & @CRLF & _
" return this.capture(elem, context, function(name, chunk) {" & @CRLF & _
" partialContext.templateName = name;" & @CRLF & _
" load(name, chunk, partialContext).end();" & @CRLF & _
" });" & @CRLF & _
" } else {" & @CRLF & _
" partialContext.templateName = elem;" & @CRLF & _
" return load(elem, this, partialContext);" & @CRLF & _
" }" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.helper = function(name, context, bodies, params, auto) {" & @CRLF & _
" var chunk = this," & @CRLF & _
" filters = params.filters," & @CRLF & _
" ret;" & @CRLF & _
"" & @CRLF & _
" // Pre-2.7.1 compat: if auto is undefined, it's an old template. Automatically escape" & @CRLF & _
" if (auto === undefined) {" & @CRLF & _
" auto = 'h';" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" // handle invalid helpers, similar to invalid filters" & @CRLF & _
" if(dust.helpers[name]) {" & @CRLF & _
" try {" & @CRLF & _
" ret = dust.helpers[name](chunk, context, bodies, params);" & @CRLF & _
" if (ret instanceof Chunk) {" & @CRLF & _
" return ret;" & @CRLF & _
" }" & @CRLF & _
" if(typeof filters === 'string') {" & @CRLF & _
" filters = filters.split('|');" & @CRLF & _
" }" & @CRLF & _
" if (!dust.isEmptyObject(bodies)) {" & @CRLF & _
" return chunk.section(ret, context, bodies, params);" & @CRLF & _
" }" & @CRLF & _
" // Helpers act slightly differently from functions in context in that they will act as" & @CRLF & _
" // a reference if they are self-closing (due to grammar limitations)" & @CRLF & _
" // In the Chunk.await function we check to make sure bodies is null before acting as a reference" & @CRLF & _
" return chunk.reference(ret, context, auto, filters);" & @CRLF & _
" } catch(err) {" & @CRLF & _
" dust.log('Error in helper `' + name + '`: ' + err.message, ERROR);" & @CRLF & _
" return chunk.setError(err);" & @CRLF & _
" }" & @CRLF & _
" } else {" & @CRLF & _
" dust.log('Helper `' + name + '` does not exist', WARN);" & @CRLF & _
" return chunk;" & @CRLF & _
" }" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Reserve a chunk to be evaluated once a thenable is resolved or rejected" & @CRLF & _
" * @param thenable {Thenable} the target thenable to await" & @CRLF & _
" * @param context {Context} context to use to render the deferred chunk" & @CRLF & _
" * @param bodies {Object} must contain a "body", may contain an "error"" & @CRLF & _
" * @param auto {String} automatically apply this filter if the Thenable is a reference" & @CRLF & _
" * @param filters {Array} apply these filters if the Thenable is a reference" & @CRLF & _
" * @return {Chunk}" & @CRLF & _
" */" & @CRLF & _
" Chunk.prototype.await = function(thenable, context, bodies, auto, filters) {" & @CRLF & _
" return this.map(function(chunk) {" & @CRLF & _
" thenable.then(function(data) {" & @CRLF & _
" if (bodies) {" & @CRLF & _
" chunk = chunk.section(data, context, bodies);" & @CRLF & _
" } else {" & @CRLF & _
" // Actually a reference. Self-closing sections don't render" & @CRLF & _
" chunk = chunk.reference(data, context, auto, filters);" & @CRLF & _
" }" & @CRLF & _
" chunk.end();" & @CRLF & _
" }, function(err) {" & @CRLF & _
" var errorBody = bodies && bodies.error;" & @CRLF & _
" if(errorBody) {" & @CRLF & _
" chunk.render(errorBody, context.push(err)).end();" & @CRLF & _
" } else {" & @CRLF & _
" dust.log('Unhandled promise rejection in `' + context.getTemplateName() + '`', INFO);" & @CRLF & _
" chunk.end();" & @CRLF & _
" }" & @CRLF & _
" });" & @CRLF & _
" });" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" /**" & @CRLF & _
" * Reserve a chunk to be evaluated with the contents of a streamable." & @CRLF & _
" * Currently an error event will bomb out the stream. Once an error" & @CRLF & _
" * is received, we push it to an {:error} block if one exists, and log otherwise," & @CRLF & _
" * then stop listening to the stream." & @CRLF & _
" * @param streamable {Streamable} the target streamable that will emit events" & @CRLF & _
" * @param context {Context} context to use to render each thunk" & @CRLF & _
" * @param bodies {Object} must contain a "body", may contain an "error"" & @CRLF & _
" * @return {Chunk}" & @CRLF & _
" */" & @CRLF & _
" Chunk.prototype.stream = function(stream, context, bodies, auto, filters) {" & @CRLF & _
" var body = bodies && bodies.block," & @CRLF & _
" errorBody = bodies && bodies.error;" & @CRLF & _
" return this.map(function(chunk) {" & @CRLF & _
" var ended = false;" & @CRLF & _
" stream" & @CRLF & _
" .on('data', function data(thunk) {" & @CRLF & _
" if(ended) {" & @CRLF & _
" return;" & @CRLF & _
" }" & @CRLF & _
" if(body) {" & @CRLF & _
" // Fork a new chunk out of the blockstream so that we can flush it independently" & @CRLF & _
" chunk = chunk.map(function(chunk) {" & @CRLF & _
" chunk.render(body, context.push(thunk)).end();" & @CRLF & _
" });" & @CRLF & _
" } else if(!bodies) {" & @CRLF & _
" // When actually a reference, don't fork, just write into the master async chunk" & @CRLF & _
" chunk = chunk.reference(thunk, context, auto, filters);" & @CRLF & _
" }" & @CRLF & _
" })" & @CRLF & _
" .on('error', function error(err) {" & @CRLF & _
" if(ended) {" & @CRLF & _
" return;" & @CRLF & _
" }" & @CRLF & _
" if(errorBody) {" & @CRLF & _
" chunk.render(errorBody, context.push(err));" & @CRLF & _
" } else {" & @CRLF & _
" dust.log('Unhandled stream error in `' + context.getTemplateName() + '`', INFO);" & @CRLF & _
" }" & @CRLF & _
" if(!ended) {" & @CRLF & _
" ended = true;" & @CRLF & _
" chunk.end();" & @CRLF & _
" }" & @CRLF & _
" })" & @CRLF & _
" .on('end', function end() {" & @CRLF & _
" if(!ended) {" & @CRLF & _
" ended = true;" & @CRLF & _
" chunk.end();" & @CRLF & _
" }" & @CRLF & _
" });" & @CRLF & _
" });" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.capture = function(body, context, callback) {" & @CRLF & _
" return this.map(function(chunk) {" & @CRLF & _
" var stub = new Stub(function(err, out) {" & @CRLF & _
" if (err) {" & @CRLF & _
" chunk.setError(err);" & @CRLF & _
" } else {" & @CRLF & _
" callback(out, chunk);" & @CRLF & _
" }" & @CRLF & _
" });" & @CRLF & _
" body(stub.head, context).end();" & @CRLF & _
" });" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Chunk.prototype.setError = function(err) {" & @CRLF & _
" this.error = err;" & @CRLF & _
" this.root.flush();" & @CRLF & _
" return this;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" // Chunk aliases" & @CRLF & _
" for(var f in Chunk.prototype) {" & @CRLF & _
" if(dust._aliases[f]) {" & @CRLF & _
" Chunk.prototype[dust._aliases[f]] = Chunk.prototype[f];" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" function Tap(head, tail) {" & @CRLF & _
" this.head = head;" & @CRLF & _
" this.tail = tail;" & @CRLF & _
" }" & @CRLF & _
"" & @CRLF & _
" Tap.prototype.push = function(tap) {" & @CRLF & _
" return new Tap(tap, this);" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" Tap.prototype.go = function(value) {" & @CRLF & _
" var tap = this;" & @CRLF & _
"" & @CRLF & _
" while(tap) {" & @CRLF & _
" value = tap.head(value);" & @CRLF & _
" tap = tap.tail;" & @CRLF & _
" }" & @CRLF & _
" return value;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" var HCHARS = /[&<>"']/," & @CRLF & _
" AMP = /&/g," & @CRLF & _
" LT = /</g," & @CRLF & _
" GT = />/g," & @CRLF & _
" QUOT = /\"/g," & @CRLF & _
" SQUOT = /\'/g;" & @CRLF & _
"" & @CRLF & _
" dust.escapeHtml = function(s) {" & @CRLF & _
" if (typeof s === "string" || (s && typeof s.toString === "function")) {" & @CRLF & _
" if (typeof s !== "string") {" & @CRLF & _
" s = s.toString();" & @CRLF & _
" }" & @CRLF & _
" if (!HCHARS.test(s)) {" & @CRLF & _
" return s;" & @CRLF & _
" }" & @CRLF & _
" return s.replace(AMP,'&').replace(LT,'<').replace(GT,'>').replace(QUOT,'"').replace(SQUOT, ''');" & @CRLF & _
" }" & @CRLF & _
" return s;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" var BS = /\\/g," & @CRLF & _
" FS = /\//g," & @CRLF & _
" CR = /\r/g," & @CRLF & _
" LS = /\u2028/g," & @CRLF & _
" PS = /\u2029/g," & @CRLF & _
" NL = /\n/g," & @CRLF & _
" LF = /\f/g," & @CRLF & _
" SQ = /'/g," & @CRLF & _
" DQ = /"/g," & @CRLF & _
" TB = /\t/g;" & @CRLF & _
"" & @CRLF & _
" dust.escapeJs = function(s) {" & @CRLF & _
" if (typeof s === 'string') {" & @CRLF & _
" return s" & @CRLF & _
" .replace(BS, '\\\\')" & @CRLF & _
" .replace(FS, '\\/')" & @CRLF & _
" .replace(DQ, '\\"')" & @CRLF & _
" .replace(SQ, '\\\'')" & @CRLF & _
" .replace(CR, '\\r')" & @CRLF & _
" .replace(LS, '\\u2028')" & @CRLF & _
" .replace(PS, '\\u2029')" & @CRLF & _
" .replace(NL, '\\n')" & @CRLF & _
" .replace(LF, '\\f')" & @CRLF & _
" .replace(TB, '\\t');" & @CRLF & _
" }" & @CRLF & _
" return s;" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" dust.escapeJSON = function(o) {" & @CRLF & _
" if (!JSON) {" & @CRLF & _
" dust.log('JSON is undefined; could not escape `' + o + '`', WARN);" & @CRLF & _
" return o;" & @CRLF & _
" } else {" & @CRLF & _
" return JSON.stringify(o)" & @CRLF & _
" .replace(LS, '\\u2028')" & @CRLF & _
" .replace(PS, '\\u2029')" & @CRLF & _
" .replace(LT, '\\u003c');" & @CRLF & _
" }" & @CRLF & _
" };" & @CRLF & _
"" & @CRLF & _
" return dust;" & @CRLF & _
"" & @CRLF & _
"}));" & @CRLF & _
"" & @CRLF & _
"if (typeof define === "function" && define.amd && define.amd.dust === true) {" & @CRLF & _
" define(["require", "dust.core"], function(require, dust) {" & @CRLF & _
" dust.onLoad = function(name, cb) {" & @CRLF & _
" require([name], function() {" & @CRLF & _
" cb();" & @CRLF & _
" });" & @CRLF & _
" };" & @CRLF & _
" return dust;" & @CRLF & _
" });" & @CRLF & _
"}" & @CRLF & _
""
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm