1'use strict';
2
3function precompileGlobal(templates, opts) {
4  var out = '';
5  opts = opts || {};
6  for (var i = 0; i < templates.length; i++) {
7    var name = JSON.stringify(templates[i].name);
8    var template = templates[i].template;
9    out += '(function() {' + '(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})' + '[' + name + '] = (function() {\n' + template + '\n})();\n';
10    if (opts.asFunction) {
11      out += 'return function(ctx, cb) { return nunjucks.render(' + name + ', ctx, cb); }\n';
12    }
13    out += '})();\n';
14  }
15  return out;
16}
17module.exports = precompileGlobal;