Synchronously create a template
510901
function templateWithArgs( apiDir, apiName, apiFuncName ) {
	cacheAPIs[apiName] = { 
		reg: (RegularCacheClient
			.replace(/%%api.root%%/g,apiDir)
			.replace(/%%api.name%%/g,apiName)
			.replace(/%%api.funcs%%/g,JSON.stringify(apiFuncName))),
		service: (ServiceCacheClient
			.replace(/%%api.root%%/g,apiDir)
			.replace(/%%api.name%%/g,apiName)
			.replace(/%%api.funcs%%/g,JSON.stringify(apiFuncName)))
	}

}
659277
function writeFileSync(templateName, templateOption, filename) {
  var templateString = fs.readFileSync(path.join(__dirname, '/templates/' + templateName), 'utf8');
  fs.writeFileSync(path.join(projectDirectory, filename), Mustache.render(templateString, templateOption));
}
107702
def saveTemplate(self):
        """"""
        savedict = {}
        for comp_editor in self.widgets():
            stim = comp_editor.component()
            comp_editor.saveToObject()
            savedict[stim.name] = stim.stateDict()
        savedict['delay'] = self.delaySpnbx.value()
        return savedict
875515
private ProcTemplate createTemplate(Template template) {
        if (!template.isEmpty()) {
            return new ProcTemplate(templateElementFactory.createTemplateList(template.getElements()));
        } else {
            return ProcTemplate.EMPTY;
        }
    }
314493
function (done) {
        glob(path.join(__dirname, "*.ejs"), function (err, files) {
            if (err) {
                return done(err);
            }

            var templates = {};

            async.forEach(files, function (file, done) {
                fs.readFile(file, "utf8", function (err, data) {
                    if (err) {
                        return done(err);
                    } else {
                        templates[path.basename(file, ".ejs")] = _.template(data);
                        done();
                    }
                });
            }, function (err) {
                if (err) {
                    return done(err);
                }

                done(null, templates);
            });
        });
    }
1061327
function renderSync(filename, options) {
  var template = getTemplate(filename, options);
  return template.render({ model: options, });
}
36307
function getTemplate(template) {
  var ret;

  store.roots.some(function(r) {
    var filepath = path.join(r, template);
    if (file.exists(filepath)) {
      ret = filepath;
      return true;
    }
  });

  return ret;
}
518120
function templateSourceUpdate(){
    if (this.destroyBuilder)
      buildTemplate.call(this);

    var cursor = this;
    while (cursor = cursor.attaches_)
      cursor.handler.call(cursor.context);
  }
1005507
function loadTemplate(templatePath, identifier) {
  return plugin.myrmex.fire('beforeTemplateLoad', templatePath, identifier)
  .spread((templatePath, name) => {
    const templateDoc = _.cloneDeep(require(path.join(templatePath)));

    // Lasy loading because the plugin has to be registered in a Myrmex instance before requiring the document
    const Template = require('./template');
    const template = new Template(templateDoc, identifier);

    // This event allows to inject code to alter the template configuration
    return plugin.myrmex.fire('afterTemplateLoad', template);
  })
  .spread(template => {
    return Promise.resolve(template);
  });
}
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();
}
566518
function createTemplate (appname, filename, data) {
  var content, ext;
  if (data) {
    data.appname = appname
  }
  if(ignoreFileTypes.test(filename)){
    console.log('Don\'t FUTZ binary files', filename);
    content = getUnrenderedTemplateContents(filename);
  } else  {
    content = getTemplateContents(filename, data)
    // ext = path.extname(filename)
  }
    fs.writeFileSync(path.join(appname, filename), content)
  
}
768437
def _exec_template(callable_, context, args=None, kwargs=None):
    
    template = context._with_template
    if template is not None and \
            (template.format_exceptions or template.error_handler):
        try:
            callable_(context, *args, **kwargs)
        except Exception:
            _render_error(template, context, compat.exception_as())
        except:
            e = sys.exc_info()[0]
            _render_error(template, context, e)
    else:
        callable_(context, *args, **kwargs)
1301240
function buildRunTemplate(opts, callback) {
  var viewOpt = {
    directory: opts.directory,
    processCommand: opts.command,
    user: opts.user,
    processEnvDir: opts.processEnvDir
  };

  renderTemplate(templateFilePath('run', opts.templateOpt), viewOpt, function(err, renderedOutput) {
    if (err) {
      return callback(err.message);
    } else {
      return fs.writeFile(opts.processRunPath, renderedOutput, function(err) {
	if (err) {
	  return callback(err.message);
	} else {
	  fs.chmodSync(opts.processRunPath, 0755);
	  return callback(null);
	}
      });
    }
  });
}
949934
def copy_templates(entry_point, py_entry_point, auto_write, output_dir):
    '''
    '''

    if not os.path.exists(output_dir):
        os.makedirs(output_dir)

    scripts = []
    for f in os.listdir(bin_path()):
        ext = os.path.splitext(f)[-1]
        newline = NEWLINE_MAP.get(ext, '\n')
        template = bin_path(f)
        destination = output_dir + '/' + entry_point + ext
        scripts.append(destination)

        with io.open(template, 'r') as f:
            code = f.read()
        code = code.replace('{{entry_point}}', entry_point)
        code = code.replace('{{py_entry_point}}', py_entry_point)
        code = code.replace('{{auto_write}}', str(int(auto_write)))

        with io.open(destination, 'w', newline=newline) as f:
            f.write(code)

    return scripts
1221754
private static void createTemplateWithJsonInElasticsearch(RestClient client, String template, String json) throws Exception {
		logger.trace("createTemplate([{}])", template);

		assert client != null;
		assert template != null;

		Request request = new Request("PUT", "/_template/" + template);
		request.setJsonEntity(json);
		Response response = client.performRequest(request);

		if (response.getStatusLine().getStatusCode() != 200) {
			logger.warn("Could not create template [{}]", template);
			throw new Exception("Could not create template ["+template+"].");
		}

		logger.trace("/createTemplate([{}])", template);
	}
793446
def template(colors, input_file, output_file=None):
    """"""
    template_data = util.read_file_raw(input_file)

    try:
        template_data = "".join(template_data).format(**colors)
    except ValueError:
        logging.error("Syntax error in template file '%s'.", input_file)
        return

    util.save_file(template_data, output_file)
591714
def _create_template(self, name):
        
        url = '%s/%s' % (self._base_url, escape.url_escape(name))
        LOGGER.debug('Making HTTP GET request to %s', url)
        response = self._http_client.fetch(url)
        data = json.loads(response.body, ensure_ascii=False)
        return template.Template(data['template'], name=name, loader=self)