Temper compiles templates to client-side compatible templates as well as it's
server side equivalents.

@constructor
@param {Object} options Temper configuration.
@api public
487588
function Temper(options) {
  if (!this) return new Temper(options);
  options = options || {};

  //
  // We only want to cache the templates in production as it's so we can easily
  // change templates when we're developing.
  //
  options.cache = 'cache' in options
    ? options.cache
    : process.env.NODE_ENV !== 'production';

  this.installed = Object.create(null);   // Installed module for extension cache.
  this.required = Object.create(null);    // Template engine require cache.
  this.compiled = Object.create(null);    // Compiled template cache.
  this.timers = new TickTock(this);       // Keep track of timeouts.
  this.file = Object.create(null);        // File lookup cache.
  this.cache = options.cache;             // Cache compiled templates.
}
526669
function (template, options) {
      var parsedTemplate
      if (!options) {
        options = {}
      }
      if (options.rdelim) {
        // If delimiters are passed locally take them.
        this.smarty.rdelim = options.rdelim
      } else if (jSmart.prototype.right_delimiter) {
        // Backward compatible. Old way to set via prototype.
        this.smarty.rdelim = jSmart.prototype.right_delimiter
      } else {
        // Otherwise default delimiters
        this.smarty.rdelim = '}'
      }
      if (options.ldelim) {
        // If delimiters are passed locally take them.
        this.smarty.ldelim = options.ldelim
      } else if (jSmart.prototype.left_delimiter) {
        // Backward compatible. Old way to set via prototype.
        this.smarty.ldelim = jSmart.prototype.left_delimiter
      } else {
        // Otherwise default delimiters
        this.smarty.ldelim = '{'
      }
      if (options.autoLiteral !== undefined) {
        // If autoLiteral is passed locally, take it.
        this.autoLiteral = options.autoLiteral
      } else if (jSmart.prototype.auto_literal !== undefined) {
        // Backward compatible. Old way to set via prototype.
        this.autoLiteral = jSmart.prototype.auto_literal
      }

      if (options.debugging !== undefined) {
        // If debugging is passed locally, take it.
        this.debugging = options.debugging
      } else if (jSmart.prototype.debugging !== undefined) {
        // Backward compatible. Old way to set via prototype.
        this.debugging = jSmart.prototype.debugging
      }

      if (options.escapeHtml !== undefined) {
        // If escapeHtml is passed locally, take it.
        this.escapeHtml = options.escapeHtml
      } else if (jSmart.prototype.escape_html !== undefined) {
        // Backward compatible. Old way to set via prototype.
        this.escapeHtml = jSmart.prototype.escape_html
      }

      // Is template string or at least defined?!
      template = String(template || '')

      // Generate the tree. We pass delimiters and many config values
      // which are needed by parser to parse like delimiters.
      jSmartParser.clear()
      jSmartParser.rdelim = this.smarty.rdelim
      jSmartParser.ldelim = this.smarty.ldelim
      jSmartParser.getTemplate = this.getTemplate
      jSmartParser.getConfig = this.getConfig
      jSmartParser.autoLiteral = this.autoLiteral
      jSmartParser.plugins = this.plugins
      jSmartParser.preFilters = this.filtersGlobal.pre
      // Above parser config are set, lets parse.
      parsedTemplate = jSmartParser.getParsed(template)
      this.tree = parsedTemplate.tree
      this.runTimePlugins = parsedTemplate.runTimePlugins
      this.blocks = parsedTemplate.blocks
      this.outerBlocks = parsedTemplate.outerBlocks
    }
777560
function client(tpl, options) {
  options = options || {};

  /**
   * The template render method which returns React DOM elements.
   *
   * @param {Object} data Template variables that should be introduced.
   * @returns {React}
   * @api public
   */
  return transform(tpl, {
    filename: options.filename,
    sourceMaps: !!options.debug,
    presets: ['react'],
  }, {
    render: options.render || (options.raw ? 'renderToStaticMarkup' : 'renderToString')
  });
}
463751
function processTemplates(templates) {
	var templateProcessingLog = logger.createTemplateProcessingLog();
	var replacements = Mix.manifest.get();
	for (let template in templates) {
		if (templates.hasOwnProperty(template)) {
			// Copy to target
			fs.copySync(template, templates[template]);
			// Compile
			compileTemplate(
				templates[template],
				replacements,
				templateProcessingLog.addTemplateFileLog(
					template,
					templates[template]
				)
			);
		}
	}
	templateProcessingLog.print();
}
1314537
function setupTemplates() {
  
  // Reset templates before proceeding
  // NOTE: This is needed for templates to be copatible with hot code loading
  this.templates = {};

  var self = this;
  var tplDir = app.mvcpath + app.paths.templates;
  var multiSlashes = this.regex.multipleSlashes;
  
  if (fs.existsSync(tplDir) && fs.statSync(tplDir).isDirectory()) {
    
    var files = protos.util.walkDir(tplDir, this.regex.templateFile);
  
    files.forEach(function(path) {
      buildTemplatePartial.call(this, path);
      watchPartial.call(this, path, buildTemplatePartial);
    }, this);
    
  }
  
  this.emit('templates_loaded', this.templates);
  
}
252039
function(options) {
        // compile regular expressions once instead of every time they are used
        this.regExes = {
            trimSpace: (/^\s*|\s*$/g),
            removeSpace: (/\s*/g),
            splitSpace: (/\s+/),
            trimComma: (/\s*,\s*/g)
        };
        OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);
    }
428436
function generateCode(taskOptions) {
  try {
    // Perform initialization tasks
    const model = taskOptions.swagger;
    debug('Processing configuration');
    const config = defaults(taskOptions, configDefaults);
    debug('  Initializing template engine');
    const templateEngine = taskOptions.templateEngine(taskOptions);
    debug('  Mapping definitions from file');
    const definitionMap = taskOptions.definitionMapper(model);

    // Execute definition templates
    /* istanbul ignore else - Trivial case */
    if (config.perDefinition) {
      debug('  Executing per-definition templates:');
      for (const templateFile of Object.keys(config.perDefinition)) {
        debug('    Iterating template: %s', templateFile);
        const options = defaults(config.perDefinition[templateFile], {
          extension: '.js',
          operations: ['get', 'put', 'post', 'delete'],
        });
        const template = taskOptions.templateLoader(templateEngine)
          .loadTemplate(templateFile, taskOptions.textEncoding);
        for (const definitionKey of Object.keys(definitionMap)) {
          const definition = definitionMap[definitionKey];

          debug('      Processing definition %s', definitionKey);
          // Copy fields from options into definition for
          const context = {
            model,
            definition,
            definitionMap,
            options,
          };

          debug('      Rendering template');
          const output = template(context);
          const subPath = path.join(options.target,
            definition.definitionName.toLowerCase() +
            options.extension);
          taskOptions.output(subPath, output);
        }
      }
    } else {
      debug('    No per-definition templates specified in perDefinition');
    }

    // Execute path templates
    if (config.perPath) {
      debug('  Executing per-path templates:');
      for (const templateFile of Object.keys(config.perPath)) {
        debug('    Processing template: %s', templateFile);
        const options = defaults(config.perPath[templateFile], {
          extension: '.js',
          operations: ['get', 'put', 'post', 'delete'],
        });
        const template = taskOptions.templateLoader(templateEngine)
          .loadTemplate(templateFile, taskOptions.textEncoding);
        debug('    Iterating paths, grouping operations by %s', options.groupBy);

        const groups = {};

        for (const pathString of Object.keys(model.paths)) {
          debug('      Path: %s', pathString);
          const pathDef = model.paths[pathString];
          let groupKey = pathDef[options.groupBy];
          pathDef.pathString = pathString;

          // Iterate through the allowed operations
          for (const operationString of _.intersection(Object.keys(pathDef), options.operations)) {
            debug('        Operation: %s', operationString);
            const operationDef = model.paths[pathString][operationString];
            groupKey = operationDef[options.groupBy] || groupKey;
            operationDef.pathDef = pathDef;
            operationDef.operationString = operationString;

            // We need a grouping key at either operation or path level
            /* istanbul ignore if */
            if (groupKey === null || groupKey === undefined) {
              throw new Error(util.format(
                'Cannot map path operation. No groupBy match at path/operation level: %s/%s [%s]',
                pathString,
                operationString,
                options.groupBy));
            }
            debug('          Assigned to output group: %s', groupKey);

            // If the group does not exist, create it
            if (groups[groupKey] === undefined) {
              groups[groupKey] = [];
            }

            // Add to group
            groups[groupKey].push(operationDef);
          } // per operationString
        } // per pathString

        debug('    Rendering template for %s group(s)', Object.keys(groups).length);
        for (const groupKey of Object.keys(groups)) {
          debug('      Processing group: %s', groupKey);

          const context = {};
          context.fileName = groupKey.trim().toLowerCase();
          context.groupKey = groupKey;
          context.members = groups[groupKey];
          context.definitionMap = definitionMap;
          context.model = model;
          context.options = options;

          const output = template(context);
          const subPath = path.join(options.target,
            context.fileName + options.extension);
          taskOptions.output(subPath, output);
        }
      } // per templateFile
    } // if perPath
  } catch (err) {
    /* istanbul ignore next - We don't wan't to test process.exit */
    taskOptions.failureHandler(err);
  }
}
1371846
function compileTemplates() {
  const mainHtml = fs.readFileSync(path.resolve(docsDir, 'src/template.html'), {
    encoding: 'utf8',
  });
  const mainTemplate = Handlebars.compile(mainHtml);

  function createPage(fileName, tab, content) {
    const html = mainTemplate({
      tabs: [{
        title: 'Get started',
        url: 'get-started.html',
        selected: tab === 'get-started',
      }, {
        title: 'Components',
        url: 'components.html',
        selected: tab === 'components',
      }],
      content,
      luiVersion: LUI_VERSION,
    });
    fileUtil.writeFile(path.resolve(docsDir, 'dist', fileName), html);
  }

  function createIndexPage() {
    const content = fs.readFileSync(path.resolve(docsDir, 'src/pages/index.html'), {
      encoding: 'utf8',
    });
    const template = Handlebars.compile(content);
    const html = template();
    return createPage('index.html', 'index', html);
  }

  function createGetStartedPage() {
    const content = fs.readFileSync(path.resolve(docsDir, 'src/pages/get-started.html'), {
      encoding: 'utf8',
    });
    const template = Handlebars.compile(content);
    const html = template({
      luiVersion: LUI_VERSION,
    });
    return createPage('get-started.html', 'get-started', html);
  }

  function createComponentPage(templateName, template, tab, content) {
    return createPage(templateName, tab, template({
      content,
      sections: sections.map(section => ({
        name: section.name,
        pages: section.pages.map(page => ({
          name: page.name,
          template: page.template,
          selected: page.template === templateName,
        })),
      })),
    }));
  }

  function createComponentPages() {
    const componentHtml = fs.readFileSync(path.resolve(docsDir, 'src/component-template.html'), {
      encoding: 'utf8',
    });
    const componentTemplate = Handlebars.compile(componentHtml);

    sections.forEach((section) => {
      section.pages.forEach((page) => {
        const file = `src/pages/${page.template}`;
        const fileContent = fs.readFileSync(path.resolve(docsDir, file), {
          encoding: 'utf8',
        });

        const template = Handlebars.compile(fileContent);
        const html = template();

        createComponentPage(page.template, componentTemplate, 'components', html);
      });
    });

    const file = 'src/pages/components.html';
    const fileContent = fs.readFileSync(path.resolve(docsDir, file), {
      encoding: 'utf8',
    });
    createComponentPage('components.html', componentTemplate, 'components', fileContent);
  }

  createIndexPage();
  createGetStartedPage();
  createComponentPages();
}
1240562
function Templater(options) {
  if (options == null) {
    options = { allowEval: true };
  }
  this.options = options;
  if (options.stack && Array.isArray(options.stack)) {
    this.stack = options.stack;
  }
  else if (typeof options.stack === 'string') {
    this.stack = [ options.stack ];
  }
  else {
    this.stack = [];
  }
  this.nodes = [];
}
194921
function renderTemplate(template, locals, cb) {
    var res;

    try {
      var localTemplateOptions = self.getLocalTemplateOptions(locals);
      var localsClone = _.extend({}, locals);
      self.updateLocalTemplateOptions(localsClone, undefined);
      res = template(localsClone, _.merge({}, self._options.templateOptions, localTemplateOptions));
    } catch (err) {
      if (err.message) {
        err.message = '[' + template.__filename + '] ' + err.message;
      } else if (typeof err === 'string') {
        return cb('[' + template.__filename + '] ' + err, null);
      }
      return cb(err, null);
    }
    cb(null, res);
  }
222231
function (rules, options) {
    this.rules = new Config(rules, options);
    this.parser = new Parser();
    this.inlineConfig = new InlineConfig(this.rules);
}
349956
function compileTemplate () {
    var template = $attrs.$mdTabsTemplate,
        element  = angular.element($element[0].querySelector('md-tab-data'));

    element.html(template);
    $compile(element.contents())(ctrl.parent);
    delete $attrs.$mdTabsTemplate;
  }
612137
function compile(tmpl, conf) {
  let str = tmpl || '';
  const c = Object.assign({}, settings, conf);
  const blocks = {};

  str = str
    // allow the use of ' in the body
    .replace(/'/g, '\\\'')

    // handle block def
    .replace(c.blockDef, (m, name, argStr, body) => {
      blocks[name] = {
        args: argStr.split(',').map(a => a.trim()),
        body,
      };
      return '';
    })

    // handle block call
    .replace(c.block, handleBlockCall(c, blocks))

    // convert models
    .replace(c.interpolate, (m, code) => `';out+=${jsValue(code)};out+='`)

    // raw js
    .replace(c.evaluate, (m, code) => `';${jsValue(code)}out+='`);

  // build the template function body
  str = `var out='${str}';return out;`
    // remove the newlines or '' will break
    .replace(/\r/g, '\\r')
    .replace(/\n/g, '\\n')
    .replace(/\t/g, '\\t')
    .replace(/(\s|;|\}|^|\{)out\+='';/g, '$1')
    .replace(/\+''/g, '');

  return new Function(c.varname, str); // eslint-disable-line
}
631367
function mergeArgumentsTemplate(template, arg, propertyName) {
  if (!template.hasOwnProperty(propertyName)) {
    template[propertyName] = {};
  }

  if (arg.hasOwnProperty(propertyName)) {

    if (!arg[propertyName]) {
      arg[propertyName] = {};
    }

    Object.keys(arg[propertyName]).forEach((key) => {
      if (template[propertyName].hasOwnProperty(key)) {
        throw new Error(propertyName + ' name used more than once: ' + key);
      }

      template[propertyName][key] = JSON.parse(JSON.stringify(arg[propertyName][key]));
    });
  }
}
860730
function template(
  { template, types: t },
  opts,
  { imports, componentName, props, jsx, exports },
) {
  const name = componentName.name.replace('Svg', '');

  jsx
    .openingElement
    .attributes = [
      t.jsxAttribute(
        t.jsxIdentifier('aria-label'),
        t.stringLiteral(`icon_${name}`)
      ),
      ...jsx.openingElement.attributes
    ];

  const titleElement = t.jsxElement(
    t.jsxOpeningElement(t.jsxIdentifier('title'), []),
    t.jsxClosingElement(t.jsxIdentifier('title')),
    [t.jsxText(`${name}`)],
  )

  jsx.children = [titleElement, ...jsx.children];

  return template.ast`
    ${imports}
    import withIcon from './withIcon';
    const ${name} = (${props}) => ${jsx}
    export default withIcon(${name});
  `
}
993776
function render(filename, options, callback) {
  var isAsync = callback && typeof callback === 'function';

  if (!isAsync) {
    return renderSync(filename, options)
  }

  getTemplate(filename, options, function(err, template) {
    if (err) {
      return callback(err);
    }

    template.render({ model: options, }, callback);
  });
}
1306753
function buildMasterTemplate(opts, callback) {
  var viewOpt = {
    app: opts.app,
    processes: opts.processes
  };

  renderTemplate(templateFilePath('master', opts.templateOpt), viewOpt, function(err, renderedOutput) {
    if (err) {
      return callback(err.message);
    } else {
      return fs.writeFile(opts.writePath, renderedOutput, function(err) {
	if (err) {
	  return callback(err.message);
	} else {
	  return callback(null);
	}
      });
    }
  });
}