check for template existance
481899
protected static function checkTemplatePresence($raw_name)
    {
        $name = str_replace('.', '/', $raw_name);
        if (file_exists(get_template_directory() . "/app/views/${name}.blade.php")) {
            return true;
        }

        if (file_exists(dirname(__DIR__) . "/views/${name}.blade.php")) {
            return true;
        }

        return false;
    }
1228429
def check_cache(self, template):
        '''
        
        '''
        if template not in self.cached:
            self.cache_file(template)
            self.cached.append(template)
684006
def template(tpl, template_adapter=SimpleTemplate, **kwargs):
    '''
    
    '''
    if tpl not in TEMPLATES or DEBUG:
        settings = kwargs.get('template_settings',{})
        lookup = kwargs.get('template_lookup', TEMPLATE_PATH)
        if isinstance(tpl, template_adapter):
            TEMPLATES[tpl] = tpl
            if settings: TEMPLATES[tpl].prepare(settings)
        elif "\n" in tpl or "{" in tpl or "%" in tpl or '$' in tpl:
            TEMPLATES[tpl] = template_adapter(source=tpl, lookup=lookup, settings=settings)
        else:
            TEMPLATES[tpl] = template_adapter(name=tpl, lookup=lookup, settings=settings)
    if not TEMPLATES[tpl]:
        abort(500, 'Template (%s) not found' % tpl)
    kwargs['abort'] = abort
    kwargs['request'] = request
    kwargs['response'] = response
    return TEMPLATES[tpl].render(**kwargs)
746805
@Deprecated
	public static boolean isTemplateExist(Client client, String template) {
		return !client.admin().indices().prepareGetTemplates(template).get().getIndexTemplates().isEmpty();
	}
1172279
private void checkTemplate(TemplateNode node, TemplateRegistry templateRegistry) {
    ListMultimap<String, SourceLocation> dataKeys = ArrayListMultimap.create();

    for (VarRefNode varRefNode : SoyTreeUtils.getAllNodesOfType(node, VarRefNode.class)) {
      if (varRefNode.isPossibleHeaderVar()) {
        dataKeys.put(varRefNode.getName(), varRefNode.getSourceLocation());
      }
    }

    IndirectParamsInfo ipi =
        new IndirectParamsCalculator(templateRegistry)
            .calculateIndirectParams(templateRegistry.getMetadata(node));

    Set<String> allHeaderVarNames = new HashSet<>();
    List<TemplateHeaderVarDefn> unusedParams = new ArrayList<>();
    // Process @param header variables.
    for (TemplateParam param : node.getAllParams()) {
      allHeaderVarNames.add(param.name());
      if (dataKeys.containsKey(param.name())) {
        // Good: Declared and referenced in template. We remove these from dataKeys so
        // that at the end of the for-loop, dataKeys will only contain the keys that are referenced
        // but not declared in SoyDoc.
        dataKeys.removeAll(param.name());
      } else if (ipi.paramKeyToCalleesMultimap.containsKey(param.name())
          || ipi.mayHaveIndirectParamsInExternalCalls
          || ipi.mayHaveIndirectParamsInExternalDelCalls) {
        // Good: Declared in SoyDoc and either (a) used in a call that passes all data or (b) used
        // in an external call or delcall that passes all data, which may need the param (we can't
        // verify).
      } else {
        // Bad: Declared in SoyDoc but not referenced in template.
        unusedParams.add(param);
      }
    }

    List<TemplateHeaderVarDefn> unusedStateVars = new ArrayList<>();
    // Process @state header variables.
    if (node instanceof TemplateElementNode) {
      TemplateElementNode el = (TemplateElementNode) node;
      for (TemplateStateVar stateVar : el.getStateVars()) {
        allHeaderVarNames.add(stateVar.name());
        if (dataKeys.containsKey(stateVar.name())) {
          // Good: declared and referenced in the template.
          dataKeys.removeAll(stateVar.name());
        } else {
          // Bad: declared in the header, but not used.
          unusedStateVars.add(stateVar);
        }
      }
    }
    // At this point, the only keys left in dataKeys are undeclared.
    for (Entry<String, SourceLocation> undeclared : dataKeys.entries()) {
      String extraErrorMessage =
          SoyErrors.getDidYouMeanMessage(allHeaderVarNames, undeclared.getKey());
      errorReporter.report(
          undeclared.getValue(), UNDECLARED_DATA_KEY, undeclared.getKey(), extraErrorMessage);
    }

    // Delegate templates can declare unused params because other implementations
    // of the same delegate may need to use those params.
    if (node instanceof TemplateBasicNode) {
      reportUnusedHeaderVars(errorReporter, unusedParams, UNUSED_PARAM);
    }
    if (node instanceof TemplateElementNode) {
      reportUnusedHeaderVars(errorReporter, unusedStateVars, UNUSED_STATE);
    }
  }
953238
def _check_config(self):
        """"""
        required_data = ['creation_date',
                         'author',
                         'status',
                         'lang',
                         'tags',
                         'title',
                         'slug',
                         'theme',
                         'template',
                         'page_id']
        isok = True
        # exclude some statements from coverage analysis. I would need to
        # refactor how the config is loaded/handled etc. It's not worth
        # to do that now. Maybe when I change yaml for the markdwn extension.
        for e in self._config.keys():
            if not e in required_data: # pragma: no cover
                print "The configuration in page '" + \
                      self._slug + "' is corrupt."
                isok = False
            # check that the theme and template exist, even if they're default.
        (pthemedir, ptemplatefname) = self._theme_and_template_fp()
        if not os.path.isdir(pthemedir): # pragma: no cover
            print "Theme " + self._config['theme'][0] + \
                  " specified in page '" + \
                  self._slug + "' does not exist."
            isok = False
        if not os.path.isfile(ptemplatefname): # pragma: no cover
            print "Template " + self._config['template'][0] + \
                  " specified in page '" + self._slug + \
                  "' does not exist."
            isok = False
        return isok
1037995
protected function templateExists($template)
    {
        $loader = $this->twig->getLoader();
        if (method_exists($loader, 'exists')) {
            return $loader->exists($template);
        }

        try {
            // cast possible TemplateReferenceInterface to string because the
            // EngineInterface supports them but Twig_LoaderInterface does not
            $loader->getSource($template)->getCode();
        } catch (\Twig_Error_Loader $e) {
            return false;
        }

        return true;
    }
984310
private function exists($templateName)
    {
        foreach ($this->templateFolderList as $templateFolder) {
            $templatePath = sprintf('%s/%s.php', $templateFolder, $templateName);
            if (file_exists($templatePath)) {
                return true;
            }
        }

        return false;
    }
870948
def _checkMissingParams(self, template, **kwargs):
        

        parameters = self.listFields(template)
        self._findMissingParams(parameters, **kwargs)
1027442
function done(err, template) {

    // cache
    if (options && options.cache && template) {
      cache.set(filename, template);
    }

    if (isAsync) {
      callback(err, template);
    }

    return template;
  }
193191
function areValidTemplateItems (template) {
  return template.every(item =>
    item != null &&
    typeof item === 'object' &&
    (item.hasOwnProperty('label') ||
     item.hasOwnProperty('role') ||
     item.type === 'separator'))
}
800465
public String renderIfTemplateExists(String template, Object... args) {
        boolean typeInferenceEnabled = conf().typeInferenceEnabled();
        if (typeInferenceEnabled) {
            ParamTypeInferencer.registerParams(this, args);
        }

        if (nonExistsTemplates.contains(template)) return "";

        String key = template;
        if (typeInferenceEnabled) {
            key += ParamTypeInferencer.uuid();
        }

        try {
            TemplateClass tc = classes().getByTemplate(template);
            if (null == tc) {
                ITemplateResource rsrc = resourceManager().getResource(template);
                if (rsrc.isValid()) {
                    tc = new TemplateClass(rsrc, this);
                    //classes().add(key, tc);
                } else {
                    nonExistsTemplates.add(template);
                    if (isDevMode() && nonExistsTemplatesChecker == null) {
                        nonExistsTemplatesChecker = new NonExistsTemplatesChecker();
                    }
                    return "";
                }
            }
            ITemplate t = tc.asTemplate(this);
            setRenderArgs(t, args);
            return t.render();
        } finally {
            renderCleanUp();
        }
    }
154461
def sbatch_template(self):
        """"""
        template = self.sbatch_template_str
        if template.startswith('#!'):
            # script is embedded in YAML
            return jinja_environment.from_string(template)
        return jinja_environment.get_template(template)
292713
def do_template(self,args):
        """"""
        parser = CommandArgumentParser("template")
        args = vars(parser.parse_args(args))

        print "reading template for stack."
        rawStack = self.wrappedStack['rawStack']
        template = AwsConnectionFactory.getCfClient().get_template(StackName=rawStack.name)
        print template['TemplateBody']
971078
public function template_exists($filename)
    {
        if (!is_array($this->template_dir)) {
            return file_exists($this->template_dir . DIRECTORY_SEPARATOR . $filename);
        } else {
            foreach ($this->template_dir as $tpl_dir) {
                if (file_exists($tpl_dir . DIRECTORY_SEPARATOR . $filename)) {
                    return true;
                }
            }

            return false;
        }
    }
17424
def render(self, name, context):
        """"""
        if Generator.strict:
            self.env.undefined = TestableUndefined
        else:
            self.env.undefined = Undefined
        template = self.get_template(name)
        return template.render(context)
1296600
def validate_template_syntax(source):
    
    try:
        Template(source)
    except (TemplateSyntaxError, TemplateDoesNotExist) as err:
        raise ValidationError(text_type(err))