compile templates from a given directory
192190
function(path, partials)
    {
      var templates = { };

      grunt.file.recurse(path, function (absPath, rootDir, subDir, filename)
      {
        // ignore non-template files
        if (!filename.match(matcher)) {
          return;
        }

        // read template source and data
        var relPath  = absPath.substr(rootDir.length + 1),
          tmpData  = absPath.replace(matcher, '.json'),
          tmpSrc   = grunt.file.read(absPath),

          // template name based on path (e.g. "index", "guide/index", etc)
          name     = relPath.replace(matcher, ''),

          // set-up template specific locals
          locals   = mustatic.merge({}, globals);

        // add template URL to locals
        locals.url = name + '.html';

        // load template data and merge into locals
        if (grunt.file.exists(tmpData)) {
          locals = mustatic.merge(locals, JSON.parse(grunt.file.read(tmpData)));
        }

        // store locals
        data[name] = locals;

        templates[name] = hogan.compile(tmpSrc);
      });

      return templates;
    }
727369
async function readTemplate (filename) {
  const templateDir = path.join(__dirname, 'template')
  return readFile(path.join(templateDir, filename), 'utf8')
}
400136
function compile (template, data) {
    for (var name in data) {
      template = template.replace('{{' + name + '}}', data[name])
    }
    return template
  }
195397
function compile(directive, ctxt, template){
    var rfn = compiler( ( template || this[0] ).cloneNode(true), directive, ctxt);
    return function(context){
      return rfn({context:context});
    };
  }
875787
def load_template(name, directory, extension, encoding, encoding_errors):
    
    abs_path = get_abs_template_path(name, directory, extension)
    return load_file(abs_path, encoding, encoding_errors)
894155
def compile(template)
      v8_context do |context|
        template = template.read if template.respond_to?(:read)
        compiled_handlebars = context.eval("Handlebars.precompile(#{template.to_json})")
        "Handlebars.template(#{compiled_handlebars});"
      end
    end
748922
def templates(self):
        """"""
        template = lib.EnvGetNextDeftemplate(self._env, ffi.NULL)

        while template != ffi.NULL:
            yield Template(self._env, template)

            template = lib.EnvGetNextDeftemplate(self._env, template)
1301937
def _ensure_dir(self, template_name):
        """"""
        head = os.path.dirname(template_name)
        if head:
            file_dirpath = os.path.join(self.outpath, head)
            if not os.path.exists(file_dirpath):
                os.makedirs(file_dirpath)
990619
def render_template(self):
        """"""
        self._parse_paths()
        context = dict(napp=self._napp.__dict__, paths=self._paths)
        self._save(context)
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
    })
}
1014901
function template(pattern) {
    return app.src(pattern, { cwd: path.join(__dirname, 'templates') })
      .pipe(app.renderFile('*')).on('error', console.error)
      .pipe(app.conflicts(app.cwd))
      .pipe(app.dest(app.options.dest || app.cwd));
  }
524973
def _compile(self, source, filename):
        
        if filename == '<template>':
            # make a better filename
            filename = 'dbt-{}'.format(
                codecs.encode(os.urandom(12), 'hex').decode('ascii')
            )
            # encode, though I don't think this matters
            filename = jinja2._compat.encode_filename(filename)
            # put ourselves in the cache
            linecache.cache[filename] = (
                len(source),
                None,
                [line + '\n' for line in source.splitlines()],
                filename
            )

        return super(MacroFuzzEnvironment, self)._compile(source, filename)
1211074
def load_template(self, path):
        
        if not path.startswith('/'):
            for folder in self.options['template_folders']:
                fullpath = op.join(folder, path)
                if op.exists(fullpath):
                    path = fullpath
                    break
            else:
                raise JadeException('Template doesnt exist: %s' % path)

        with open(path, 'rb') as f:
            source = f.read().decode(self.options['encoding'])

        return ExtendCompiler(
            pyjade.parser.Parser(source).parse(), pretty=self.options['pretty'],
            env=self, compileDebug=True
        )
1345382
function compileFile(module, filename) {
		const templateString = fs.readFileSync(filename, 'utf8');

		module.exports = handlebars.compile(templateString);
	}
1127326
def get_template_dir():
    """"""
    try:
        template_dir = os.path.expanduser(os.environ["NET_TEXTFSM"])
        index = os.path.join(template_dir, "index")
        if not os.path.isfile(index):
            # Assume only base ./ntc-templates specified
            template_dir = os.path.join(template_dir, "templates")
    except KeyError:
        # Construct path ~/ntc-templates/templates
        home_dir = os.path.expanduser("~")
        template_dir = os.path.join(home_dir, "ntc-templates", "templates")

    index = os.path.join(template_dir, "index")
    if not os.path.isdir(template_dir) or not os.path.isfile(index):
        msg = """
Valid ntc-templates not found, please install https://github.com/networktocode/ntc-templates
and then set the NET_TEXTFSM environment variable to point to the ./ntc-templates/templates
directory."""
        raise ValueError(msg)
    return os.path.abspath(template_dir)
171772
def _get_template_dirs(type="plugin"):
    
    template_dirs = [
        os.path.expanduser(os.path.join(USER_CONFIG_DIR, "templates", type)),
        os.path.join("rapport", "templates", type)  # Local dev tree
    ]
    return template_dirs
1218757
function template(files, staticPath) {
			return files ? files.map(function(filepath){
				paths = filepath.split(staticPath)[1].split('/')
				jsonpart = buildJsonPath(paths, filepath);
				return jsonpart;
			}) : ''
		}