Scans given template for mustache keys (syntax {{value}}).

@return empty list if no mustache key is found.
356219
public static List<String> getMustacheKeys(final String template) {
        final Set<String> keys = new HashSet<>();

        if (StringUtils.isNotEmpty(template)) {
            final Matcher matcher = MUSTACHE_PATTERN.matcher(template);

            while(matcher.find()) {
                keys.add(matcher.group(1));
            }

        }

        return new ArrayList<>(keys);
    }
654286
public static String mergeFromTemplate(String template, Map<String, ?> values) {
        for (String param : values.keySet()) {
            template = template.replace("{{" + param + "}}", values.get(param) == null ? "" : values.get(param).toString());
        }
        return template.replaceAll("\n|\r|  ", "");
    }
1077604
def Get(self,key):
		

		for template in self.templates:
			if template.id == key:  return(template)
1044889
def extract_vars(template):
    
    keys = set()
    for match in re.finditer(r"\{\{ (?P<key>\w+) \}\}", template.getvalue()):
        keys.add(match.groups()[0])
    return sorted(list(keys))
36302
private static List<Template> sortTemplates(List<Template> templates)
	{
		List<Template> result = new ArrayList<Template>();
		for (Template t : templates)
		{
			int pos = 0;
			while (pos < result.size()
					&& t.getPos().getStart() > result.get(pos).getPos()
							.getStart())
			{
				pos++;
			}
			result.add(pos, t);
		}
		return result;
	}
1024307
@SuppressWarnings("unchecked")
    public <T extends XPathBuilder> T setTemplate(final String key, final String value) {
        if (value == null) {
            templates.remove(key);
        } else {
            templates.put(key, value);
        }
        return (T) this;
    }
327319
public ImmutableList<TemplateMetadata> getTemplates(CallNode node) {
    if (node instanceof CallBasicNode) {
      String calleeName = ((CallBasicNode) node).getCalleeName();
      TemplateMetadata template = basicTemplatesOrElementsMap.get(calleeName);
      return template == null ? ImmutableList.of() : ImmutableList.of(template);
    } else {
      String calleeName = ((CallDelegateNode) node).getDelCalleeName();
      return delTemplateSelector.delTemplateNameToValues().get(calleeName);
    }
  }
1034150
function format(template, values) {
	return Object
		.entries(values)
		.filter(
			([key]) => /^[a-z0-9_-]+$/gi.test(key)
		)
		.map(
			([key, value]) =>
				[new RegExp(`([^{]|^){${key}}([^}]|$)`,'g'), `$1${value}$2`]
		)
		.reduce(
			(str, [regexp, replacement]) => {
				return str.replace(regexp, replacement)
			}, template
		)
		.replace(/({|}){2}/g, '$1')
}
923775
function (scanner, quote) {
  if (quote) {
    if (scanner.peek() !== quote)
      return null;
    scanner.pos++;
  }

  var tokens = [];
  var charsTokenToExtend = null;

  var charRef;
  while (true) {
    var ch = scanner.peek();
    var templateTag;
    var curPos = scanner.pos;
    if (quote && ch === quote) {
      scanner.pos++;
      return tokens;
    } else if ((! quote) && (HTML_SPACE.test(ch) || ch === '>')) {
      return tokens;
    } else if (! ch) {
      scanner.fatal("Unclosed attribute in tag");
    } else if (quote ? ch === '\u0000' : ('\u0000"\'<=`'.indexOf(ch) >= 0)) {
      scanner.fatal("Unexpected character in attribute value");
    } else if (ch === '&' &&
               (charRef = getCharacterReference(scanner, true,
                                                quote || '>'))) {
      tokens.push(charRef);
      charsTokenToExtend = null;
    } else if (scanner.getTemplateTag &&
               ((templateTag = scanner.getTemplateTag(
                 scanner, TEMPLATE_TAG_POSITION.IN_ATTRIBUTE)) ||
                scanner.pos > curPos /* `{{! comment}}` */)) {
      if (templateTag) {
        tokens.push({t: 'TemplateTag',
                     v: assertIsTemplateTag(templateTag)});
        charsTokenToExtend = null;
      }
    } else {
      if (! charsTokenToExtend) {
        charsTokenToExtend = { t: 'Chars', v: '' };
        tokens.push(charsTokenToExtend);
      }
      charsTokenToExtend.v += (ch === '\r' ? '\n' : ch);
      scanner.pos++;
      if (quote && ch === '\r' && scanner.peek() === '\n')
        scanner.pos++;
    }
  }
}
802240
public void forAllForeignkeys(String template, Properties attributes) throws XDocletException
    {
        for (Iterator it = _curTableDef.getForeignkeys(); it.hasNext(); )
        {
            _curForeignkeyDef = (ForeignkeyDef)it.next();
            generate(template);
        }
        _curForeignkeyDef = null;
    }
820559
@Override
	public boolean contains(String key, String groupId, String templateId, String version) {
		doChacheEntry(key);

		return null != getCacheEntry(key);
	}
1347038
protected Map<String, String> parseNamespaces(final String template)
   {
      Map<String, String> namespaces = CollectionUtils.newHashMap();
      Document document = XmlUtils.documentFromString(template);
      Element element = document.getDocumentElement();
      NamedNodeMap attributes = element.getAttributes();

      for (int loop = 0, length = attributes.getLength(); loop < length; loop++)
      {
         org.w3c.dom.Node node = attributes.item(loop);
         String nodeName = node.getNodeName();
         int indexOf = nodeName.indexOf(XMLNS_PREFIX);

         if (indexOf == -1)
         {
            continue;
         }

         namespaces.put(nodeName.substring(indexOf + XMLNS_PREFIX.length()), node.getNodeValue());
      }

      return namespaces;
   }
816943
def validate_template_name(self, key, value):
        
        if value not in dict(current_app.config['PAGES_TEMPLATES']):
            raise ValueError(
                'Template "{0}" does not exist.'.format(value))
        return value
436401
def get_template(name, region=None, key=None, keyid=None, profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    try:
        template = conn.get_template(name)
        log.info('Retrieved template for stack %s', name)
        return template
    except BotoServerError as e:
        log.debug(e)
        msg = 'Template {0} does not exist'.format(name)
        log.error(msg)
        return six.text_type(e)
1207267
static String[] computeTemplates(String[] templates, String classpathRoot) {
        if (templates == null || templates.length == 0) {
            if (logger.isDebugEnabled()) {
                logger.debug("Automatic discovery is activated. Looking for template files in classpath under [{}].",
                        classpathRoot);
            }

            ArrayList<String> autoTemplates = new ArrayList<>();

            try {
                // Let's scan our resources
                List<String> scannedTemplates = TemplateFinder.findTemplates(classpathRoot);
                for (String template : scannedTemplates) {
                    autoTemplates.add(template);
                }

                return autoTemplates.toArray(new String[autoTemplates.size()]);
            } catch (IOException|URISyntaxException e) {
                logger.debug("Automatic discovery does not succeed for finding json files in classpath under " + classpathRoot + ".");
                logger.trace("", e);
            }
        }
        return templates;
    }
401123
public static function contains($value, array $params, Template $template)
    {
        if (empty($params) || count($params) < 2 || !isset($params['then'])) {
            throw new TemplateException(TemplateException::UNKNOWN_PARAM_FILTER, ['name' => __METHOD__]);
        }
        $params['else'] = isset($params['else']) ? $params['else'] : null;
        $template = clone $template;
        $placeholders = [];
        $placeholders['output'] = $value;

        return StringHelper::contains($value, $template->replace($params['is']))
            ? $template->replace($params['then'], $placeholders)
            : $template->replace($params['else'], $placeholders);
    }
526669
function (template, options) {
      var parsedTemplate
      if (!options) {
        options = {}
      }
      if (options.rdelim) {
        // If delimiters are passed locally take them.
        this.smarty.rdelim = options.rdelim
      } else if (jSmart.prototype.right_delimiter) {
        // Backward compatible. Old way to set via prototype.
        this.smarty.rdelim = jSmart.prototype.right_delimiter
      } else {
        // Otherwise default delimiters
        this.smarty.rdelim = '}'
      }
      if (options.ldelim) {
        // If delimiters are passed locally take them.
        this.smarty.ldelim = options.ldelim
      } else if (jSmart.prototype.left_delimiter) {
        // Backward compatible. Old way to set via prototype.
        this.smarty.ldelim = jSmart.prototype.left_delimiter
      } else {
        // Otherwise default delimiters
        this.smarty.ldelim = '{'
      }
      if (options.autoLiteral !== undefined) {
        // If autoLiteral is passed locally, take it.
        this.autoLiteral = options.autoLiteral
      } else if (jSmart.prototype.auto_literal !== undefined) {
        // Backward compatible. Old way to set via prototype.
        this.autoLiteral = jSmart.prototype.auto_literal
      }

      if (options.debugging !== undefined) {
        // If debugging is passed locally, take it.
        this.debugging = options.debugging
      } else if (jSmart.prototype.debugging !== undefined) {
        // Backward compatible. Old way to set via prototype.
        this.debugging = jSmart.prototype.debugging
      }

      if (options.escapeHtml !== undefined) {
        // If escapeHtml is passed locally, take it.
        this.escapeHtml = options.escapeHtml
      } else if (jSmart.prototype.escape_html !== undefined) {
        // Backward compatible. Old way to set via prototype.
        this.escapeHtml = jSmart.prototype.escape_html
      }

      // Is template string or at least defined?!
      template = String(template || '')

      // Generate the tree. We pass delimiters and many config values
      // which are needed by parser to parse like delimiters.
      jSmartParser.clear()
      jSmartParser.rdelim = this.smarty.rdelim
      jSmartParser.ldelim = this.smarty.ldelim
      jSmartParser.getTemplate = this.getTemplate
      jSmartParser.getConfig = this.getConfig
      jSmartParser.autoLiteral = this.autoLiteral
      jSmartParser.plugins = this.plugins
      jSmartParser.preFilters = this.filtersGlobal.pre
      // Above parser config are set, lets parse.
      parsedTemplate = jSmartParser.getParsed(template)
      this.tree = parsedTemplate.tree
      this.runTimePlugins = parsedTemplate.runTimePlugins
      this.blocks = parsedTemplate.blocks
      this.outerBlocks = parsedTemplate.outerBlocks
    }