Public: resolves a template file by looking in the template path.

 template  - the template name.
 extension - the extension of the desired template.

 Returns a string with the full path of the template file, or nil if it is not
 found.
553054
def which(template, extension)
      template_with_extension = with_extension(template, extension)

      path = absolute_paths.find do |path|
        File.exists?(File.join(path, template_with_extension))
      end

      if path
        File.join(path, template_with_extension)
      end
    end
391871
def find_template(views, name, engine)
      yield ::File.join(views, "#{name}.#{@preferred_extension}")

      if Tilt.respond_to?(:mappings)
        Tilt.mappings.each do |ext, engines|
          next unless ext != @preferred_extension and engines.include? engine
          yield ::File.join(views, "#{name}.#{ext}")
        end
      else
        Tilt.default_mapping.extensions_for(engine).each do |ext|
          yield ::File.join(views, "#{name}.#{ext}") unless ext == @preferred_extension
        end
      end
    end
1239395
def resolve_file(mgr, filename):
	
	path = importlib_resources.path('pmxbot.web.templates', filename)
	return str(mgr.enter_context(path))
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
94628
def get_template(self, name):
        """"""
        filename = path.join(self.search_path, *[p for p in name.split('/')
                                                 if p and p[0] != '.'])
        if not path.exists(filename):
            raise TemplateNotFound(name)
        return Template.from_file(filename, self.encoding)
1063770
def get_template(template_name,fields=None):
    '''
    '''
    template = None
    if not template_name.endswith('.html'):
        template_name = "%s.html" %(template_name)
    here = "%s/cli/app/templates" %(get_installdir())
    template_path = "%s/%s" %(here,template_name)
    if os.path.exists(template_path):
        template = ''.join(read_file(template_path))
    if fields is not None:
        for tag,sub in fields.items():
            template = template.replace(tag,sub)
    return template
547195
def template_path(self):
        
        return super(HideCodeHTMLExporter, self).template_path + [os.path.join(os.path.dirname(__file__), "Templates")]
1001397
def get_file_extension(file_path):
    
    _ext = os.path.splitext(file_path)[-1]
    if _ext:
        return _ext[1:] if _ext.startswith('.') else _ext

    return ""
205077
function resolveTemplateFiles(name) {
    // Create paths for resolving
    var customFile = customDir + '/' + name + '.js',
        customTemplateDir = customDir + '/' + name + '/**/*',
        stdFile = stdDir + '/' + name + '.js',
        stdTemplateDir = stdDir + '/' + name + '/**/*';

    // Grab any and all files
    var customFiles = expandFiles(customFile).concat(expandFiles(customTemplateDir)),
        stdFiles = expandFiles(stdFile).concat(expandFiles(stdTemplateDir));

    // Generate a hash of files
    var fileMap = {};

    // Iterate over the customFiles
    customFiles.forEach(function (file) {
      // Extract the relative path of the file
      var relPath = path.relative(customDir, file);

      // Save the relative path
      fileMap[relPath] = file;
    });

    // Iterate over the stdFiles
    stdFiles.forEach(function (file) {
      // Extract the relative path of the file
      var relPath = path.relative(stdDir, file),
          overrideExists = fileMap[relPath];

      // If it does not exist, save it
      if (!overrideExists) {
        fileMap[relPath] = file;
      }
    });

    // Return the fileMap
    return fileMap;
  }
1123563
private String resolveTemplate(boolean toValue)
   {
      String result = template;
      if (StringUtils.isEmptyTrimmed(result))
         return result;

      String key;

      while ((key = StringUtils.getExpressionKey(result)) != null)
      {
         String subs;
         Expression ex = entities.get(key);
         String nKey = StringUtils.getExpressionKey(ex.getDefaultValue());
         if (toValue)
            subs = ex.getValue();
         else if (nKey != null && ex.getResolvedValue() != null &&
               ex.getDefaultValue().equals(nKey))
         {
            entities.get(nKey).setResolvedValue(ex.getResolvedValue());
            subs = ex.toString();
         }
         else
            subs = ex.toSubstitution();

         result = result.replace(key, subs);
      }
      return result;
   }
1145595
def template_name(self, path, base):
        """"""
        if not base:
            path = os.path.basename(path)
        if path == base:
            base = os.path.dirname(path)
        name = re.sub(r"^%s[\/\\]?(.*)%s$" % (
            re.escape(base), re.escape(settings.TEMPLATE_EXT)
        ), r"\1", path)
        return re.sub(r"[\/\\]", settings.TEMPLATE_SEPARATOR, name)
1217929
def get_template(name, base=None):
    '''
    '''
    # If the file doesn't exist, assume relative to base
    template_file = name
    if not os.path.exists(template_file):
        if base is None:
            base = get_templatedir()
        template_file = "%s/%s" %(base, name)

    # Then try again, if it still doesn't exist, bad name
    if os.path.exists(template_file):
        with open(template_file,"r") as filey:
            template = "".join(filey.readlines())
        return template
    bot.error("%s does not exist." %template_file)
220883
function getTemplate (templates, fileName) {
  var extMatch = fileName.match(/\.([^\.]*)$/);
  if (extMatch && extMatch.length > 1)
    return templates[extMatch[1]];
  return null;
}
358325
function resolveFile(baseDirs, addType, fileName, type, cb)
{
  // The label this file will have in the output
  // For hbs views, this is the name that it will be save as into the template array.
  var label = pathlib.basename(fileName);

  // Label can be overridden with entries of the form: "label:file-name-or-path"
  var idx = fileName.indexOf(':');
  if ( idx > 0 )
  {
    label = fileName.substr(0,idx);
    fileName = fileName.substr(idx+1);
  }

  // Construct a list of paths to check
  var paths = [];
  baseDirs.forEach(function(baseDir) {
    if ( addType )
      baseDir += '/'+type;

    // Search for exact filename
    paths.push(pathlib.resolve(baseDir,fileName));

    // And with the type as an extension
    paths.push(pathlib.resolve(baseDir,fileName+'.'+type));

    // Special case 'view' because it used to mean hbs
    if ( type == 'view' )
    {
      VIEW_TYPES.forEach(function(altType) {
        paths.push(pathlib.resolve(baseDir,fileName+'.'+altType));
      });
    }
  });

  // Async
  if ( cb )
  {
    async.detectSeries(paths, fs.exists, function(result) {
      if ( result )
        return cb(undefined, label+':'+result);
      else
        return cb(new Error(errStr));
    });
  }
  else
  {
    // Sync
    for ( i=0 ; i < paths.length ; i++ )
    {
      if ( fs.existsSync(paths[i]) )
      {
        return label+':'+paths[i];
      }
    }

    throw new Error('Unable to find source ' + type + ' file for ' + fileName + ' in ' + paths.join(', '));
  }
}
199876
function readTemplate() {
    return fs.readFileSync(path.resolve.apply(null, [__dirname, settings.paths.templates, ...arguments]), 'utf8');
}
1130790
def find_template_from_path(filepath, paths=None):
    
    if paths is None or not paths:
        paths = [os.path.dirname(filepath), os.curdir]

    for path in paths:
        candidate = os.path.join(path, filepath)
        if os.path.exists(candidate):
            return candidate

    LOGGER.warning("Could not find template=%s in paths=%s", filepath, paths)
    return None
306533
def resolve_template(template):
    ""
    if isinstance(template, (list, tuple)):
        return loader.select_template(template)
    elif isinstance(template, basestring):
        try:
            return loader.get_template(template)
        except TemplateDoesNotExist:
            return None
    else:
        return template