Repack all the templates in ClientBuilder.template_dir.
322354
def RepackAllTemplates(self, upload=False, token=None):
    """"""
    for template in os.listdir(config.CONFIG["ClientBuilder.template_dir"]):
      template_path = os.path.join(config.CONFIG["ClientBuilder.template_dir"],
                                   template)

      self.RepackTemplate(
          template_path,
          os.path.join(config.CONFIG["ClientBuilder.executables_dir"],
                       "installers"),
          upload=upload,
          token=token)
      # If it's windows also repack a debug version.
      if template_path.endswith(".exe.zip"):
        print("Repacking as debug installer: %s." % template_path)
        self.RepackTemplate(
            template_path,
            os.path.join(config.CONFIG["ClientBuilder.executables_dir"],
                         "installers"),
            upload=upload,
            token=token,
            context=["DebugClientBuild Context"])
99965
def render_template_directory(deck, arguments):
    """"""
    output_directory = dir_name_from_title(deck.title)

    if os.path.exists(output_directory):
        if sys.stdout.isatty():
            if ask(
                '%s already exists, shall I delete it?' % output_directory,
                arguments.get('--noinput')
            ):
                shutil.rmtree(output_directory)
        else:
            shutil.rmtree(output_directory)

    # copy support files to output directory
    template_directory_path = (
        '%s/templates/%s' %
        (remarkable.__path__[0], deck.presentation_type)
    )
    shutil.copytree(
        template_directory_path,
        output_directory,
    )

    # copy resources
    if os.path.exists('resources'):
        log.info('Copying resources')
        shutil.copytree('resources', '%s/resources' % output_directory)
    else:
        log.info('No resources to copy')

    # render template
    template_filename = '%s/index.html' % deck.presentation_type
    html = render_template(template_filename, deck.json)

    # write index to output directory
    index_filename = '%s/index.html' % output_directory
    write_file(index_filename, html)

    return output_directory
788395
def template(client, force):
    """"""
    import pkg_resources

    # create the templated files
    for tpl_file in CI_TEMPLATES:
        tpl_path = client.path / tpl_file
        with pkg_resources.resource_stream(__name__, tpl_file) as tpl:
            content = tpl.read()

            if not force and tpl_path.exists():
                click.confirm(
                    'Do you want to override "{tpl_file}"'.format(
                        tpl_file=tpl_file
                    ),
                    abort=True,
                )

            with tpl_path.open('wb') as dest:
                dest.write(content)
1308063
def _RepackTemplates(self):
    """"""
    dummy_config = os.path.join(
        args.grr_src, "grr/test/grr_response_test/test_data/dummyconfig.yaml")
    if args.build_32:
      template_i386 = glob.glob(os.path.join(args.output_dir,
                                             "*_i386*.zip")).pop()
    template_amd64 = glob.glob(os.path.join(args.output_dir,
                                            "*_amd64*.zip")).pop()

    # We put the installers in the output dir so they get stored as build
    # artifacts and we can test the 32bit build manually.
    subprocess.check_call([
        self.grr_client_build64, "--verbose", "--secondary_configs",
        dummy_config, "repack", "--template", template_amd64, "--output_dir",
        args.output_dir
    ])
    subprocess.check_call([
        self.grr_client_build64, "--verbose", "--context",
        "DebugClientBuild Context", "--secondary_configs", dummy_config,
        "repack", "--template", template_amd64, "--output_dir", args.output_dir
    ])
    if args.build_32:
      subprocess.check_call([
          self.grr_client_build32, "--verbose", "--secondary_configs",
          dummy_config, "repack", "--template", template_i386, "--output_dir",
          args.output_dir
      ])
      subprocess.check_call([
          self.grr_client_build32, "--verbose", "--context",
          "DebugClientBuild Context", "--secondary_configs", dummy_config,
          "repack", "--template", template_i386, "--output_dir", args.output_dir
      ])
103995
def render_template(templates_path, template_filename, context):
        """"""
        template_env = Environment(
            autoescape=False, trim_blocks=False,
            loader=FileSystemLoader(str(templates_path)))
        return template_env.get_template(str(template_filename)) \
            .render(context)
1014944
def run(self):
        ''''''
        for tpl in self.templates:
            for provider in tpl.providers:
                provider.provide()
1132223
def template(client, src, dest, paths, opt):
    """"""
    key_map = cli_hash(opt.key_map)
    obj = {}
    for path in paths:
        response = client.read(path)
        if not response:
            raise aomi.exceptions.VaultData("Unable to retrieve %s" % path)
        if is_aws(response['data']) and 'sts' not in path:
            renew_secret(client, response, opt)

        for s_k, s_v in response['data'].items():
            o_key = s_k
            if s_k in key_map:
                o_key = key_map[s_k]

            k_name = secret_key_name(path, o_key, opt) \
                .lower() \
                .replace('-', '_')
            obj[k_name] = s_v

    template_obj = blend_vars(obj, opt)
    output = render(grok_template_file(src),
                    template_obj)
    write_raw_file(output, abspath(dest))
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);
  
}
552258
private static function clear_templates()
    {
        $dir_iterator = new RecursiveDirectoryIterator(static::$root . '/resources/templates');
        $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);

        foreach ($iterator as $file) {
            if (!\is_dir($file) && \strpos($file, '_example.php') === false) {
                @\unlink($file);
            }
        }
    }
179179
private String buildTemplates() {
		String[] templateString = new String[model.getTemplates().size()];
		for (int i = 0; i < (model.getTemplates().size()); i++) {
			String templateLoaded = loadTemplateFile(
					model.getTemplates().get(i));
			if (templateLoaded != null) {
				templateString[i] = templateLoaded;
			}
		}
		return implode(templateString, File.pathSeparator);
	}
355950
public function all()
    {
        $this->out('<info>Compiling all templates</info>');

        foreach (Scanner::all() as $section => $templates) {
            $this->out('<info>Compiling ' . $section . '\'s templates</info>');
            $this->walkIterator($templates);
        }
    }
585705
function loadTemplatesFiles (dir, files, options, templates) {
    // require files
    if (!Array.isArray(files)) {
        return Promise.resolve()
    }
    // load template for each file
    return Promise.each(files, file => {
        // get absolute file from dir
        var absFile = dir+'/'+file
        // get express template name by stripping off extension
        file = file.replace(GLOBAL.extRegExp, '')
        // if template has already been defined then do not replace so that
        // first incidence of file in multiple paths is used
        if (templates[file]) {
            return
        }
        // load template
        var promise = templates[file] = loadTemplate(absFile, options)
        // once template is loaded replace promise with template
        .then(template => {
            templates[file] = template
        })
        // wait for template to load
        return promise
    })
}
208589
def template_files(include_bundled_software)
      result = {
        "kit" => ".",
        "packages" => ".",
        "src" => "."
      }

      if include_bundled_software
        Dir.chdir(TEMPLATE_PATH) do
          Dir.glob(File.join("bundled", "*")).each do |file|
            result[file] = "kit"
          end
        end
      end

      result
    end
521191
def reset(self):
        """"""
        with self.lock:
            if self.cache:
                if self.use_tmp:
                    shutil.rmtree(self.tmp_dir, ignore_errors=True)
                else:
                    self.templates = {}
1037893
function setTemplate(transformDir, templateName, clientType) {
    clientType = clientType ? (clientType + '.') : '';

    if (templateCache[templateName]) {
        this.template = templateCache[templateName];
    }
    else {
        var fileName = transformDir + '/' + clientType + templateName + '.template';

        if (fs.existsSync(path.normalize(fileName))) {
            var file = fs.readFileSync(path.normalize(fileName));
            this.template = templateCache[templateName] = dot.template(file);
        }
        else {
            throw new Error('No template at ' + fileName);
        }
    }
}
783359
def compile(self, name, folder=None, data=None):
        
        template_name = name.replace(os.sep, "")
        if folder is None:
            folder = ""
        full_name = os.path.join(
            folder.strip(os.sep), template_name)
        if data is None:
            data = {}
        try:
            self.templates[template_name] = \
                self.jinja.get_template(full_name).render(data)
        except TemplateNotFound as template_error:
            if current_app.config['DEBUG']:
                raise template_error
258129
def populate_files_from_append_templates
        @append_templates.each do |x|
          new_name = x.sub(/_([lL]?)\._{1}/, '')
          FileUtils.touch(FileUtils.join_paths(@install_path, @project_name, new_name))
          FileUtils.append_to_end_of_file(FileUtils.join_paths(@template_path, x), FileUtils.join_paths(@install_path, @project_name, new_name), JumpStart::Base.remove_last_line?(x))
        end
      end