set chunk contents as template data property and render it with a layout
@param  {object} chunk stream chunk object
@return {object}       chunk with applied layout
15985
function applyLayout(chunk) {
    chunk.data.contents = String(chunk.contents);
    var layout = getLayout(chunk.data.layout),
        contents = options.renderTemplate(layout.contents, chunk.data, layout.path);
    chunk.contents = new Buffer(contents);
    return chunk;
  }
725953
function cacheAndCompile(filename, str) {
    var layout_template = handlebars.compile(str);
    if (options.cache) {
      cache[filename] = layout_template;
    }

    render_with_layout(layout_template, options, cb);
  }
273619
function render_with_layout(template, locals, cb) {
    render_file(locals, function(err, str) {
      if (err) {
        return cb(err);
      }

      locals.body = str;

      var res = template(locals, handlebarsOpts);
      self.async.done(function(values) {
        Object.keys(values).forEach(function(id) {
          res = res.replace(id, values[id]);
        });

        cb(null, res);
      });
    });
  }
1276229
function render(file, layout, context, partials, callback) {
  try {
    const data = mustache.render(layout, context, partials);
    async.nextTick(callback, null, data);
  } catch (error) {
    console.error(`${file.path}: Could not render the layout`);
    async.nextTick(callback, error);
  }
}
1203548
function transformChunkData(chunk) {
    var matter = grayMatter(String(chunk.contents)),
        relPath = chunk.hasOwnProperty('data') && chunk.data.relativePath ?
          chunk.data.relativePath : getRelativePath(chunk.relative),
        absPath = path.normalize(path.join(options.basePath, relPath));
    chunk.data = merge.recursive({},
      options.data,
      {
        basePath: options.basePath,
        relativePath: relPath,
        path: absPath,
        urlPath: options.prettyUrls ? path.dirname(absPath) + '/' : absPath,
        srcBasePath: chunk.base,
        srcRelativePath: chunk.relative,
        srcPath: chunk.path,
        contents: '',
        draft: false,
        layout: options.defaultLayout
      },
      chunk.data || {},
      matter.data
    );
    chunk.contents = new Buffer(matter.content);
    chunk.path = path.join(chunk.base, relPath);
    return chunk;
  }
1111787
function render(content, data) {
    if (content && /{{([^{}]+)}}/g.test(content)) {
        Object.keys(data).forEach(key => {
            if (data[key] && typeof data[key] === 'string') {
                content = content.split(new RegExp(`{{\\s*${key}\\s*}}`, 'g')).join(data[key]);
            }
        });
        return content;
    }

    return content;
}
147953
function $stream(ctx, qs, initCB, config) {

    const $p = config.promise;

    // istanbul ignore next:
    // we do not provide code coverage for the Native Bindings specifics
    if (ctx.options.pgNative) {
        return $p.reject(new Error(npm.text.nativeStreaming));
    }
    if (!qs || !qs.constructor || qs.constructor.name !== 'PgQueryStream') {
        // stream object wasn't passed in correctly;
        return $p.reject(new TypeError(npm.text.invalidStream));
    }
    if (qs._reading || qs._closed) {
        // stream object is in the wrong state;
        return $p.reject(new Error(npm.text.invalidStreamState));
    }
    if (typeof initCB !== 'function') {
        // parameter `initCB` must be passed as the initialization callback;
        return $p.reject(new TypeError(npm.text.invalidStreamCB));
    }

    let error = npm.events.query(ctx.options, getContext());

    if (error) {
        error = getError(error);
        npm.events.error(ctx.options, error, getContext());
        return $p.reject(error);
    }

    const stream = ctx.db.client.query(qs);

    stream.on('data', onData);
    stream.on('error', onError);
    stream.on('end', onEnd);

    try {
        initCB.call(this, stream); // the stream must be initialized during the call;
    } catch (e) {
        release();
        error = getError(e);
        npm.events.error(ctx.options, error, getContext());
        return $p.reject(error);
    }

    const start = Date.now();
    let resolve, reject, nRows = 0, cache = [];

    function onData(data) {
        cache.push(data);
        nRows++;
        if (cache.length >= qs.batchSize) {
            notify();
        }
    }

    function onError(e) {
        release();
        stream.close();
        e = getError(e);
        npm.events.error(ctx.options, e, getContext());
        reject(e);
    }

    function onEnd() {
        release();
        notify();
        resolve({
            processed: nRows, // total number of rows processed;
            duration: Date.now() - start // duration, in milliseconds;
        });
    }

    function release() {
        stream.removeListener('data', onData);
        stream.removeListener('error', onError);
        stream.removeListener('end', onEnd);
    }

    function notify() {
        if (cache.length) {
            const context = getContext();
            error = npm.events.receive(ctx.options, cache, undefined, context);
            cache = [];
            if (error) {
                onError(error);
            }
        }
    }

    function getError(e) {
        return e instanceof npm.utils.InternalError ? e.error : e;
    }

    function getContext() {
        let client;
        if (ctx.db) {
            client = ctx.db.client;
        } else {
            error = new Error(npm.text.looseQuery);
        }
        return {
            client,
            dc: ctx.dc,
            query: qs.cursor.text,
            params: qs.cursor.values,
            ctx: ctx.ctx
        };
    }

    return $p((res, rej) => {
        resolve = res;
        reject = rej;
    });

}
1082749
function storeTmplItems( content ) {
		var keySuffix = "_" + cloneIndex, elem, elems, newClonedItems = {}, i, l, m;
		for ( i = 0, l = content.length; i < l; i++ ) {
			if ( (elem = content[i]).nodeType !== 1 ) {
				continue;
			}
			elems = elem.getElementsByTagName("*");
			for ( m = elems.length - 1; m >= 0; m-- ) {
				processItemKey( elems[m] );
			}
			processItemKey( elem );
		}
		function processItemKey( el ) {
			var pntKey, pntNode = el, pntItem, tmplItem, key;
			// Ensure that each rendered template inserted into the DOM has its own template item,
			if ( (key = el.getAttribute( tmplItmAtt ))) {
				while ( pntNode.parentNode && (pntNode = pntNode.parentNode).nodeType === 1 && !(pntKey = pntNode.getAttribute( tmplItmAtt ))) { }
				if ( pntKey !== key ) {
					// The next ancestor with a _tmplitem expando is on a different key than this one.
					// So this is a top-level element within this template item
					// Set pntNode to the key of the parentNode, or to 0 if pntNode.parentNode is null, or pntNode is a fragment.
					pntNode = pntNode.parentNode ? (pntNode.nodeType === 11 ? 0 : (pntNode.getAttribute( tmplItmAtt ) || 0)) : 0;
					if ( !(tmplItem = newTmplItems[key]) ) {
						// The item is for wrapped content, and was copied from the temporary parent wrappedItem.
						tmplItem = wrappedItems[key];
						tmplItem = newTmplItem( tmplItem, newTmplItems[pntNode]||wrappedItems[pntNode], null, true );
						tmplItem.key = ++itemKey;
						newTmplItems[itemKey] = tmplItem;
					}
					if ( cloneIndex ) {
						cloneTmplItem( key );
					}
				}
				el.removeAttribute( tmplItmAtt );
			} else if ( cloneIndex && (tmplItem = jQuery.data( el, "tmplItem" )) ) {
				// This was a rendered element, cloned during append or appendTo etc.
				// TmplItem stored in jQuery data has already been cloned in cloneCopyEvent. We must replace it with a fresh cloned tmplItem.
				cloneTmplItem( tmplItem.key );
				newTmplItems[tmplItem.key] = tmplItem;
				pntNode = jQuery.data( el.parentNode, "tmplItem" );
				pntNode = pntNode ? pntNode.key : 0;
			}
			if ( tmplItem ) {
				pntItem = tmplItem;
				// Find the template item of the parent element. 
				// (Using !=, not !==, since pntItem.key is number, and pntNode may be a string)
				while ( pntItem && pntItem.key != pntNode ) { 
					// Add this element as a top-level node for this rendered template item, as well as for any
					// ancestor items between this item and the item of its parent element
					pntItem.nodes.push( el );
					pntItem = pntItem.parent;
				}
				// Delete content built during rendering - reduce API surface area and memory use, and avoid exposing of stale data after rendering...
				delete tmplItem._ctnt;
				delete tmplItem._wrap;
				// Store template item as jQuery data on the element
				jQuery.data( el, "tmplItem", tmplItem );
			}
			function cloneTmplItem( key ) {
				key = key + keySuffix;
				tmplItem = newClonedItems[key] = 
					(newClonedItems[key] || newTmplItem( tmplItem, newTmplItems[tmplItem.parent.key + keySuffix] || tmplItem.parent, null, true ));
			}
		}
	}
334035
function (f, content) {
    var path = config.getLayout(f);
    if (!path) return content;
    if (!fss.exists(path)) return content;
    return compile(f, fss.readFile(path),
        _.extend(templateData({}), { content: content }));
}
796279
function render(data) {
                if (!this._rendered) {
                    if (this.template) {
                        if (data) {
                            this.data = data;
                        }
                        var options = this._options,
                            parentChildren = this._parentChildren,
                            decoder = new Decoder(this.template),
                            template = decoder.render(this.data);
                        if (this.el) {
                            var parent = this.el.parentNode;
                            if (parent) {
                                parent.replaceChild(template.fragment, this.el);
                            }
                            if (this.elGroup && this.elGroup.get(this.el)) {
                                this.elGroup.delete(this.el);
                                this.el = template.fragment;
                                this.elGroup.set(template.fragment, this);
                            }
                        } else {
                            this.el = template.fragment;
                        }

                        this.root = new dom.Element(template.fragment, {
                            name: 'root',
                            data: {}
                        });

                        this.children = applyElement(template.children, options);
                        applyParent(this, parentChildren, this.data);
                        this.bindings = setBinders(this.children, true);

                        if (this.data) {
                            this.applyBinders(this.data, this);
                        }

                        setRoutes(this.children, this.context);
                        addChildren(this, this.root);
                        this.rendered.apply(this, _toConsumableArray(this._arguments));
                        this._rendered = true;
                    } else {
                        var HTMLelement = document.createElement('div');
                        this.root = new dom.Element(HTMLelement, {
                            name: 'root',
                            data: {}
                        });
                        if (this.el) {
                            var _parent = this.el.parentNode;
                            if (_parent) {
                                _parent.replaceChild(HTMLelement, this.el);
                            }
                        }
                        this.el = HTMLelement;
                        this.children = {};
                        addChildren(this, this.root);

                        this.rendered.apply(this, _toConsumableArray(this._arguments));
                        this._rendered = true;
                    }
                }
            }
558595
function TemplateFile(path) {

    this._buffer = FS.readFileSync(path, {"encoding": "utf8"});
    if (!this._buffer || this._buffer.length === 0) {
        throw new Error("Could not read " + path);
    }
}
1158600
function(stream, callback) {
                    var content = '';
                    stream.on('data', function(chunk) {
                      content += chunk;
                    });
                    stream.on('end', function() {
                      callback(content);
                    });
                  }
722179
function (cb, data, layout) {
            var self = this;

            Y.prepare([DEFAULT_THEME, themeDir], self.getProjectMeta(), function (err, opts) {
                if (err) {
                    console.log(err);
                }
                if (!data.name) {
                    return;
                }

                opts.meta = Y.merge(opts.meta, data);

                opts.meta.title = self.data.project.name;
                opts.meta.moduleName = data.name;
                opts.meta.projectRoot = '../';
                opts.meta.projectAssets = '../assets';
                opts.meta.projectLogo = self._resolveUrl(self.data.project.logo, opts);

                opts = self.populateClasses(opts);
                opts = self.populateModules(opts);
                opts = self.populateFiles(opts);

                opts.meta.fileName = data.name;
                fs.readFile(opts.meta.fileName, Y.charset, Y.rbind(function (err, str, opts, data) {
                    if (err) {
                        Y.log(err, 'error', 'builder');
                        cb(err);
                        return;
                    }

                    if (typeof self.options.tabspace === 'string') {
                        str = str.replace(/\t/g, self.options.tabspace);
                    }

                    opts.meta.fileData = str;
                    var view = new Y.DocView(opts.meta, 'index');
                    var mainLayout = opts.layouts[layout];
                    self.render('{{>files}}', view, mainLayout, opts.partials, function (err, html) {
                        self.files++;
                        cb(html, view, data);
                    });

                }, this, opts, data));
            });

        }
726607
function format(fn) {
  return function(chunk) {
    if (arguments.length > 1) {
      chunk = util.format.apply(null, arguments);
    }
    if (chunk === undefined) {
      chunk = '';
    }
    fn.call(this, chunk);
  };
}
1232817
function renderContent(source, generator, context, options, cb) {
    ejs.renderFile(generator.templatePath(source), context, options, (err, res) => {
        if (!err) {
            cb(res);
        } else {
            generator.error(`Copying template ${source} failed. [${err}]`);
        }
    });
}
808699
function render (file, options, callback) {
    debug('render', file, options)
    // load layouts
    var layouts = loadLayouts(options)
    // load partials
    var partials = loadPartials(options)
    // get template function
    var template = loadTemplate(file, options)
    // wait for all promises to resolve
    return Promise.all([
        layouts,
        partials,
        template,
    ])
    // once all promises resolved render template
    .then(all => {
        var layouts = all[0]
        var partials = all[1]
        var template = all[2]
        // render options
        var hbsOptions = {
            helpers: GLOBAL.helpers,
            partials: partials,
        }
        // render template
        var body = template(options, hbsOptions)
        // get layout from options or default layout
        var layout = options.layout || GLOBAL.defaultLayout
        // use layout if found
        if (layout && layouts[layout]) {
            // pass layout contents of template render along with other params
            options.body = body
            // render layout
            body = layouts[layout](options, hbsOptions)
        }
        // if callback is passed then call with result
        if (callback) {
            callback(null, body)
        }
        // otherwise resolve with result
        else {
            return body
        }
    })
}
459772
function hotDownloadUpdateChunk(chunkId) {
/******/ 		var head = document.getElementsByTagName("head")[0];
/******/ 		var script = document.createElement("script");
/******/ 		script.charset = "utf-8";
/******/ 		script.src = __webpack_require__.p + "static/webpack/" + chunkId + "." + hotCurrentHash + ".hot-update.js";
/******/ 		;
/******/ 		head.appendChild(script);
/******/ 	}