Compile the JSX template from client-side usage.

@param {String} tpl JSX template string.
@param {Object} options Compilation configuration.
@returns {Function}
@api public
4159
function server(tpl, options) {
  options = options || {};

  /**
   * The template render method which uses the compiled React-template to do all
   * the things.
   *
   * @param {Object} data Template variables that should be introduced.
   * @param {Object} config Override configuration.
   * @returns {String}
   * @api public
   */
  return (new Function('React', 'ReactDOM', 'return '+ transform(tpl, {
    filename: options.filename,
    sourceMaps: !!options.debug,
    presets: ['react'],
  }, {
    render: options.render || (options.raw ? 'renderToStaticMarkup' : 'renderToString')
  })))(React, ReactDOM);
}
600959
function _createTemplateTree(templates) {
  const tree = {};

  for (const tpl of templates) {
    const parsed = Template.fromFile(tpl).parse();

    for (const [, sectionAttrs] of Object.entries(parsed)) {
      const sectionName = sectionAttrs.name;

      tree[sectionName] = tree[sectionName] || { form: false, options: {}, fields: {} };
      Object.assign(tree[sectionName].options, sectionAttrs.params);
      tree[sectionName].form = tree[sectionName].form || sectionAttrs.keyword === 'form';

      for (const [, fieldAttrs] of Object.entries(sectionAttrs.fields)) {
        const fieldName = fieldAttrs.name;
        tree[sectionName].fields[fieldName] = Object.assign({ type: 'text' }, tree[sectionName].fields[fieldName] || {}, fieldAttrs.params);
      }
    }
  }

  return tree;
}
169911
function compile(template, context) {
        for (var name in context) {
            template = template.replace('{{' + name + '}}', context[name])
        }
        return template
    }
293575
function TpBuilderProcess(str, options){
    let init = str;
    if (typeof str === 'object') {
        init = init.map((item) => '{{@ ' + item + ' }}').join('\n');
    }
    return new TpBuilder(init, options).parse();
}
1171561
function (tplCtxt) {
            this.$assert(133, tplCtxt.$TemplateCtxt);

            var toLoad = tplCtxt.getCSSDependencies();
            var tplClasspath = tplCtxt.tplClasspath;
            var loadResult = this.loadClassPathDependencies(tplClasspath, toLoad, {
                isTemplate : true
            });

            if (loadResult.changes) {
                this.$raiseEvent({
                    name : "styleChange",
                    templateClasspath : tplClasspath
                });
            }

            this.$raiseEvent({
                name : "dependenciesLoaded",
                templateClasspath : tplClasspath
            });

            return loadResult.classes;
        }
569029
function Plugin(options) {

  options = options || {};

  var reactOptions = {
    harmony: typeof options.harmony === 'undefined' ? true : options.harmony,
    stripTypes: typeof options.stripTypes === 'undefined' ? true : options.stripTypes
  };

  if (options.template && options.template.indexOf('<') === -1) {
    options.template = fs.readFileSync(options.template, {encoding: 'utf8'});
  }

  var originalJsTransform = require.extensions['.js'];

  var reactTransform = function(module, filename) {
    if (filename.indexOf('node_modules') === -1) {
      var src = fs.readFileSync(filename, {encoding: 'utf8'});
      src = appendJsxPragma(filename, src);
      src = ReactTools.transform(src, reactOptions);
      module._compile(src, filename);
    } else {
      originalJsTransform(module, filename);
    }
  };

  require.extensions['.js'] = reactTransform;
  require.extensions['.jsx'] = reactTransform;

  // Creates a stream through which each file will pass
  var stream = through.obj(function(file, enc, cb) {

    if (!file.isNull()) {

      if (file.isStream()) {
        this.emit('error', new PluginError(PLUGIN_NAME, 'Streams are not supported!'));
        return cb();
      }

      if (file.isBuffer()) {

        try {
          var contents = file.contents.toString('utf8');
          contents = appendJsxPragma(file.path, contents);
          contents = ReactTools.transform(contents, reactOptions);
          var m = new Module();
          m.id = file.path;
          m.filename = file.path;
          m.paths = module.paths.slice(1);
          m._compile(contents, file.path);
          var Component = m.exports;
          var markup = options.staticMarkup ? renderToStaticMarkup(Component) : renderToString(Component);

          if (options.template) {
            var data = _.extend({}, (typeof(options.data) == 'function' ? options.data(file) : options.data));
            data.body = markup;

            // Set default values to avoid null-reference exceptions
            data.title = data.title || '';
            data.description = data.description || '';
            data.keywords = data.keywords || '';

            markup = template(options.template, data);
          }

          file.contents = new Buffer(markup);
          var filename = gutil.replaceExtension(file.path, '.html');

          if (typeof options.hyphenate === 'undefined' || options.hyphenate) {
            filename = hyphenate(path.basename(filename));
            filename = filename.lastIndexOf('-', 0) === 0 ? filename.substring(1) : filename;
            filename = path.join(path.dirname(file.path), filename);
          }

          file.path = filename;
        } catch (err) {
          this.emit('error', new PluginError(PLUGIN_NAME, err));
          return cb();
        }
      }
    }

    // Make sure the file goes through the next gulp plugin
    this.push(file);
    // Tell the stream engine that we are done with this file
    return cb();
  });

  // Return the file stream
  return stream;
}
1136483
function injectTemplate(template) {
  let js = [
    '',
    'var __vue__options__ = (module.exports.__esModule) ?',
    'module.exports.default : module.exports;',
    '__vue__options__.template = ' + JSON.stringify(template) + ';',
    '',
  ];

  return js.join(os.EOL);
}
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 = [];
}
482440
function(template) {
    if (template && !template.compiled) {
      // Set compiling flag on fragments, but don't turn it false until the outermost template is done
      var lastCompilingValue = this.compiling;
      this.compiling = true;
      // Set this before compiling so we don't get into infinite loops if there is template recursion
      template.compiled = true;
      template.bindings = compile(this, template);
      this.compiling = lastCompilingValue;
    }
    return template;
  }
1174513
function compileTemplate(file, replacements, templateFileLog) {
	file = File.find(path.resolve(file));
	let content = file.read();
	let tags = content.match(new RegExp(tplTagRegExpStr, 'g'));
	if (tags && tags.length) {
		content = getCompiledContent(
			file,
			content.split(new RegExp(tplTagRegExpStr)),
			tags,
			replacements,
			templateFileLog
		);
		file.write(content);
	}
}
1101912
function getTplPath(tpl) {
  const tplFile = path.join(__dirname, './templates', tpl);
  const customTplDir =
    _.get(config.getRekitConfig(), 'rekitReact.templateDir') ||
    path.join(paths.map('.rekit-react/templates'));
  const customTplFile = path.join(customTplDir, tpl);
  return fs.existsSync(customTplFile) ? customTplFile : tplFile;
}
968852
function compile(template) {
    el = $compile(template)(pageScope);
    root = $rootElement.append(el)[0];
    body = $document[0].body;
    body.appendChild(root);

    pageScope.$apply();

    return el;
  }
402527
def compile(source, options = {})
      source  = prepare_source(source)
      options = prepare_options(options)
      snippet = compilation_snippet \
        method:    "compile#{ "Client" if options[:client] }",
        arguments: [source, options],
        locals:    options.fetch(:locals, {}),
        options:   options
      result  = @execjs.eval(snippet)
      process_result(source, result, options)
    rescue ExecJS::ProgramError => e
      raise engine::CompilationError, e.message
    end
244325
function(params, options) {
      var t = this;

      // If raw text was sent to the template, compile and return
      if (t.get('text')) {
        t.compile();
        return;
      }

      // Watch for changes in the text element
      t.on('change:text', t.compile, t);

      // Process a file template
      var path = t.get('path');
      if (path) {
        // Load the file
        if (t.asyncLoad) {
          FS.readFile(path, function(err, text) {
            if (err) {
              return console.error('Error reading file: ' + path, err);
            }
            t.set({text: text.toString()});
          });
        } else {
          t.set({text: FS.readFileSync(path).toString()});
        }

        // Watch the file for changes
        if (t.get('watchFile')) {
          t._watchFile();
        }
      }
    }
816373
function (data, option, callback) {
            var html = '';
            var self = this;
            var fn = self.fn;
            if (typeof option === 'function') {
                callback = option;
                option = null;
            }
            option = option || {};
            callback = callback || function (error, ret) {
                if (error) {
                    if (!(error instanceof Error)) {
                        error = new Error(error);
                    }
                    throw error;
                }
                html = ret;
            };
            var name = self.config.name;
            if (!name && fn.TPL_NAME) {
                name = fn.TPL_NAME;
            }
            var scope = new Scope(data), buffer = new LinkedBuffer(callback).head;
            renderTpl({
                name: name,
                fn: fn,
                runtime: { commands: option.commands },
                root: self
            }, scope, buffer);
            return html;
        }
1357840
function compileFile(locals, cb) {
    getSourceTemplate(function(err, source, template) {
      if (err) return cb(err);

      // Try to get the layout
      parseLayout(source, filename, function(err, layoutTemplates) {
        if (err) return cb(err);

        function renderIt(layoutTemplates) {
          if (self._options.beautify) {
            return render(template, locals, layoutTemplates, function(err, html) {
              if (err) return cb(err);
              loadBeautify();
              return cb(null, self.beautify(html, self.beautifyrc));
            });
          }
          return render(template, locals, layoutTemplates, cb);
        }

        // Determine which layout to use

        if (typeof options.layout !== 'undefined' && !options.layout) {
          // If options.layout is falsy, behave as if no layout should be used - suppress defaults
          renderIt(null);
        } else if (layoutTemplates) {
          // 1. Layout specified in template
          renderIt(layoutTemplates);
        } else if (typeof options.layout !== 'undefined' && options.layout) {
          // 2. Layout specified by options from render
          var layoutFile = self.layoutPath(filename, options.layout);
          self.cacheLayout(layoutFile, options.cache, function(err, layoutTemplates) {
            if (err) return cb(err);
            renderIt(layoutTemplates);
          });
        } else if (self.defaultLayoutTemplates) {
          // 3. Default layout specified when middleware was configured.
          renderIt(self.defaultLayoutTemplates);
        } else {
          // render without a template
          renderIt(null);
        }
      });
    });
  }
343837
function compile(template) {
        Mustache.parse(template);
        return function (view, partials) {
          return Mustache.render(template, view, partials);
        };
      }