Function taking a parsed template tag
    to a MacroKwargNode.
482568
def do_macro_kwarg(parser, token):
    
    try:
        tag_name, keyword = token.split_contents()
    except ValueError:
        raise template.TemplateSyntaxError(
            "{0} tag requires exactly one argument, a keyword".format(
                token.contents.split()[0]))

    # add some validation of the keyword argument here.
    nodelist = parser.parse(('endmacro_kwarg',))
    parser.delete_first_token()
    return MacroKwargNode(keyword, nodelist)
264201
function (f, data, context) {
    try {
        return _.template(data)(context);
    } catch(e) {
        log('error', 'could not parse template file', f);
        throw(e);
    }
}
656008
function template(url, params) {
	var templated = url;
	var keys = _.keys(params);
	var loweredKeys = _.map(keys, function (key) {
		return key.toLowerCase();
	});
	var keyLookup = _.zipObject(loweredKeys, keys);

	_.each(templateParams(url), function replaceParam(param) {
		var normalisedParam = param.toLowerCase().substr(1);

		if (!keyLookup[normalisedParam]) {
			throw new Error('Missing ' + normalisedParam);
		}

		templated = templated.replace(param,
			params[keyLookup[normalisedParam]]);
		delete params[keyLookup[normalisedParam]];
	});

	return templated;
}
1174513
function compileTemplate(file, replacements, templateFileLog) {
	file = File.find(path.resolve(file));
	let content = file.read();
	let tags = content.match(new RegExp(tplTagRegExpStr, 'g'));
	if (tags && tags.length) {
		content = getCompiledContent(
			file,
			content.split(new RegExp(tplTagRegExpStr)),
			tags,
			replacements,
			templateFileLog
		);
		file.write(content);
	}
}
843681
function getEffectiveArgumentType(node, argIndex, arg) {
            // Decorators provide special arguments, a tagged template expression provides
            // a special first argument, and string literals get string literal types
            // unless we're reporting errors
            if (node.kind === 143 /* Decorator */) {
                return getEffectiveDecoratorArgumentType(node, argIndex);
            }
            else if (argIndex === 0 && node.kind === 176 /* TaggedTemplateExpression */) {
                return getGlobalTemplateStringsArrayType();
            }
            // This is not a synthetic argument, so we return 'undefined'
            // to signal that the caller needs to check the argument.
            return undefined;
        }
1006142
def parse_template(template):
    """"""
    m = TEMPLATE_OVERRIDE_RE.match(template)
    if not m:
        return template, 0
    return m.group('template'), int(m.group('depth'))
751656
function templateFunc(str, data) {

  const func = function(obj) {
    return str.replace(/<%=([^%]*)%>/g, match => {
      //match t("...")
      let s = match.match(/t\s*\(([^)]+)\)/g);
      //replace with translation
      if (s.length) {
        s = obj.t(s[0].match(/"([^"]+)"/g)[0].split('"').join(""));
      }
      //use object[name]
      else {
        s = match.match(/([a-z\-A-Z]+([a-z\-A-Z0-9]?[a-zA-Z0-9]?)?)/g)[0];
        s = obj[s] || s;
      }
      return s;
    });
  };
  // Figure out if we're getting a template, or if we need to
  // load the template - and be sure to cache the result.
  const fn = !/<[a-z][\s\S]*>/i.test(str) ? templates[str] = templates[str] || templateFunc(globals.templates[str]) : func;

  // Provide some basic currying to the user
  return data ? fn(data) : fn;
}
490962
private boolean maybeParseImpliedThisMethod( int iOffset, int iLineNum, int iColumn, LazyLightweightParserState state, String strFunction, int markBeforeTypeArgs, int iLocBeforeTypeArgs )
  {
    if( getTokenizerInstructor() != null || getScriptPart() != null && TemplateGenerator.GS_TEMPLATE_PARSED.equals( getScriptPart().getId() ) )
    {
      // templates can only access static members from its optional super class
      return false;
    }

    ISymbol thisSym = getSymbolTable().getThisSymbolFromStackOrMap();
    if( thisSym == null || getPropertyNameFromMethodNameIncludingSetter( strFunction ) == null )
    {
      return false;
    }

    backtrack( markBeforeTypeArgs, iLocBeforeTypeArgs );

    // Make a synthetic 'this' qualifier
    Identifier root = new Identifier();
    root.setSymbol( thisSym, getSymbolTable() );
    root.setSynthetic( true );
    root.setType( thisSym.getType() );
    pushExpression( root );
    setLocation( getTokenizer().getTokenStart(), iLineNum, iColumn, true, true );
    popExpression();

    // Try to parse 'Xxx()' as implicitly qualified 'this.Xxx()'
    parseMemberAccess( root, MemberAccessKind.NORMAL, iOffset, strFunction, state, false );
    return true;
  }
174028
def inclusion_tag(self, name, context_class=Context, takes_context=False):
        
        def tag_decorator(tag_func):

            @wraps(tag_func)
            def tag_wrapper(parser, token):

                class InclusionTagNode(template.Node):

                    def render(self, context):
                        if not getattr(self, "nodelist", False):
                            try:
                                request = context["request"]
                            except KeyError:
                                t = get_template(name)
                            else:
                                ts = templates_for_device(request, name)
                                t = select_template(ts)

                            self.template = t
                        parts = [template.Variable(part).resolve(context)
                                 for part in token.split_contents()[1:]]
                        if takes_context:
                            parts.insert(0, context)
                        result = tag_func(*parts)
                        autoescape = context.autoescape
                        context = context_class(result, autoescape=autoescape)
                        return self.template.render(context)

                return InclusionTagNode()
            return self.tag(tag_wrapper)
        return tag_decorator
611540
def macro(parser, token):
    '''
    
    '''
    name = token.strip()
    parser.build_method(name, endnodes=['endmacro'])
    return ast.Yield(value=ast.Str(s=''))
596305
function getTemplate(sName,sPrefix) {
    var tp = typeof sName;
    if (tp != 'string') {
      if (reactIsValid_(sName)) {
        iTagType = 3;
        return sName;   // sName is ReactElement
      }
      else if (tp == 'function') {
        iTagType = 2;
        return sName;
      }
      else return null; // error
    }
    
    var temp, shadowCls = sPrefix? W.$main[sPrefix]: null;
    if (!shadowCls) {   // if has shadowCls, not use cached template
      temp = dTempSet[sName];
      if (temp || temp === null) {
        iTagType = 0;
        return temp;
      }
    }
    
    var ch, b = sName.split('.'), sAttr = b.shift();
    if (b.length == 0 && ((ch=sAttr[0]) < 'A' || ch > 'Z')) {
      iTagType = 1;
      return sAttr;     // createClass_(sAttr); // such as: ['div',{}]
    }
    else iTagType = 0;
    
    temp = T[sAttr];
    while (temp && (sAttr = b.shift())) {
      temp = temp[sAttr];
    }
    if (!temp || !temp._extend)
      dTempSet[sName] = temp = null;  // set null, no try next time
    else {
      if (shadowCls)
        temp = createClass_(temp._extend(shadowCls));
      else dTempSet[sName] = temp = createClass_(temp._extend());
    }
    return temp;
  }
1098547
def do_get_pages_with_tag(parser, token):
    
    bits = token.split_contents()
    if 4 != len(bits):
        raise TemplateSyntaxError('%r expects 2 arguments' % bits[0])
    if bits[-2] != 'as':
        raise TemplateSyntaxError(
            '%r expects "as" as the second last argument' % bits[0])
    varname = bits[-1]
    tag = parser.compile_filter(bits[1])
    varname = bits[-1]
    return GetPagesWithTagNode(tag, varname)
1353555
def sub_template(template,template_tag,substitution):
    '''
    '''
    template = template.replace(template_tag,substitution)
    return template
434341
function(template, context, partials, in_recursion) {
        // tit for tat
        var that = this;

        var new_regex = function() {
          return new RegExp(that.otag + "(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?" +
            that.ctag + "+", "g");
        };

        var regex = new_regex();
        var tag_replace_callback = function(match, operator, name) {
          switch(operator) {
          case "!": // ignore comments
            return "";
          case "=": // set new delimiters, rebuild the replace regexp
            that.set_delimiters(name);
            regex = new_regex();
            return "";
          case ">": // render partial
            return that.render_partial(name, context, partials);
          case "{": // the triple mustache is unescaped
            return that.find(name, context);
          default: // escape the value
            return that.escape(that.find(name, context));
          }
        };
        var lines = template.split("\n");
        for(var i = 0; i < lines.length; i++) {
          lines[i] = lines[i].replace(regex, tag_replace_callback, this);
          if(!in_recursion) {
            this.send(lines[i]);
          }
        }

        if(in_recursion) {
          return lines.join("\n");
        }
      }
87195
def compiled(template, delimiters=DEFAULT_DELIMITERS):
    
    re_tag = delimiters_to_re(delimiters)

    # variable to save states
    tokens = []
    index = 0
    sections = []
    tokens_stack = []

    # root token
    root = Root('root')
    root.filters = copy.copy(filters)

    m = re_tag.search(template, index)
    while m is not None:
        token = None
        last_literal = None
        strip_space = False

        if m.start() > index:
            last_literal = Literal('str', template[index:m.start()], root=root)
            tokens.append(last_literal)

        # parse token
        prefix, name, suffix = m.groups()

        if prefix == '=' and suffix == '=':
            # {{=| |=}} to change delimiters
            delimiters = re.split(r'\s+', name)
            if len(delimiters) != 2:
                raise SyntaxError('Invalid new delimiter definition: ' + m.group())
            re_tag = delimiters_to_re(delimiters)
            strip_space = True

        elif prefix == '{' and suffix == '}':
            # {{{ variable }}}
            token = Variable(name, name, root=root)

        elif prefix == '' and suffix == '':
            # {{ name }}
            token = Variable(name, name, root=root)
            token.escape = True

        elif suffix != '' and suffix != None:
            raise SyntaxError('Invalid token: ' + m.group())

        elif prefix == '&':
            # {{& escaped variable }}
            token = Variable(name, name, root=root)

        elif prefix == '!':
            # {{! comment }}
            token = Comment(name, root=root)
            if len(sections) <= 0:
                # considered as standalone only outside sections
                strip_space = True

        elif prefix == '>':
            # {{> partial}}
            token = Partial(name, name, root=root)
            strip_space = True

            pos = is_standalone(template, m.start(), m.end())
            if pos:
                token.indent = len(template[pos[0]:m.start()])

        elif prefix == '#' or prefix == '^':
            # {{# section }} or # {{^ inverted }}

            # strip filter
            sec_name = name.split('|')[0].strip()
            token = Section(sec_name, name, root=root) if prefix == '#' else Inverted(name, name, root=root)
            token.delimiter = delimiters
            tokens.append(token)

            # save the tokens onto stack
            token = None
            tokens_stack.append(tokens)
            tokens = []

            sections.append((sec_name, prefix, m.end()))
            strip_space = True

        elif prefix == '/':
            tag_name, sec_type, text_end = sections.pop()
            if tag_name != name:
                raise SyntaxError("unclosed tag: '" + tag_name + "' Got:" + m.group())

            children = tokens
            tokens = tokens_stack.pop()

            tokens[-1].text = template[text_end:m.start()]
            tokens[-1].children = children
            strip_space = True

        else:
            raise SyntaxError('Unknown tag: ' + m.group())

        if token is not None:
            tokens.append(token)

        index = m.end()
        if strip_space:
            pos = is_standalone(template, m.start(), m.end())
            if pos:
                index = pos[1]
                if last_literal: last_literal.value = last_literal.value.rstrip(spaces_not_newline)

        m = re_tag.search(template, index)

    tokens.append(Literal('str', template[index:]))
    root.children = tokens
    return root
1340181
def plugitInclude(parser, token):
    
    bits = token.split_contents()

    if len(bits) != 2:
        raise TemplateSyntaxError("'plugitInclude' tag takes one argument: the tempalte's action to use")

    action = parser.compile_filter(bits[1])

    return PlugItIncludeNode(action)
1225936
function getTopLevelIndentByTemplateTag(templateTag) {
            const baseIndentText = getActualLineIndentText(
                templateTag.loc.start.line
            )
            return new ExpectedIndent(
                baseIndentText,
                options.indentSize * options.startIndent
            )
        }