Extend template with custom tag
@return NULL
@param $tag string
@param $func callback
500040
function extend($tag,$func) {
		$this->tags.='|'.$tag;
		$this->custom['_'.$tag]=$func;
	}
932635
public function check(DOMElement $template, Tag $tag)
	{
		// Regexp that matches the function call
		$regexp = '#(?!<\\pL)' . preg_quote($this->funcName, '#') . '\\s*\\(#iu';

		// Allow whitespace around colons (NOTE: colons are unnecessarily escaped by preg_quote())
		$regexp = str_replace('\\:', '\\s*:\\s*', $regexp);

		foreach ($this->getExpressions($template) as $expr => $node)
		{
			// Remove string literals from the expression
			$expr = preg_replace('#([\'"]).*?\\1#s', '', $expr);

			// Test whether the expression contains a document() call
			if (preg_match($regexp, $expr))
			{
				throw new UnsafeTemplateException('An XPath expression uses the ' . $this->funcName . '() function', $node);
			}
		}
	}
646585
protected function addTemplateFunction($templateFunction, $functionName)
    {
        $function = new TwigFunction($templateFunction, $functionName);
        $this->tpl->addFunction($function);
        return $this;
    }
442060
@SuppressWarnings("unchecked")
    public <T extends XPathBuilder> T setTag(final String tag) {
        this.tag = tag;
        return (T) this;
    }
861473
public function addTag($tag, $message = null)
    {
        if ($message === null) {
            $message = $tag;
        }
        return $this->run("tag -a $tag -m $message");
    }
905359
public function addTag(Tag $tag)
    {
        // Add tag if not existing
        if (!$this->hasTag($tag)) {
            $this->tags[$tag->getTag()] = $tag;
        }

        // Increment counter if no override in the Tag entity
        if ($tag->getCounter() === null) {
            $tag->incCounter();
        }

        // Store the max counter
        if ($tag->getCounter() > $this->max) {
            $this->max = $tag->getCounter();
        }

        return $this;
    }
961054
def render_tag(self, tag_func):
        
        @wraps(tag_func)
        def tag_wrapper(parser, token):
            class RenderTagNode(template.Node):
                def render(self, context):
                    return tag_func(context, token)
            return RenderTagNode()
        return self.tag(tag_wrapper)
714082
public static function tag( $name, $param1 = null, $param2 = null ) 
	{
		return static::create( $name, $param1, $param2 );
	}
257014
public function text($type, $tag)
    {
        $this->deprecate('text');
        if (isset($this->text[$type]))
            return $this->text[$type]->get($tag);

        return null;
    }
1086579
def onTagAdd(self, name, func):
        '''
        

        '''
        # TODO allow name wild cards
        if '*' in name:
            self.ontagaddglobs.add(name, func)
        else:
            self.ontagadds[name].append(func)
1056103
public function getTag($tag)
    {
        return isset($this->tags[$tag]) ? $this->tags[$tag] : null;
    }
329902
private static function processTag(BaseTag $tag)
    {
        $types = [];

        if (method_exists($tag, 'getType') && is_callable([$tag, 'getType'])) {
            if (($type = $tag->getType()) !== null) {
                $types[] = $type;
            }
        }

        if (method_exists($tag, 'getArguments') && is_callable([$tag, 'getArguments'])) {
            foreach ($tag->getArguments() as $param) {
                if (($type = $param['type'] ?? null) !== null) {
                    $types[] = $type;
                }
            }
        }

        return $types;
    }
872408
@SuppressWarnings("unchecked")
    public T addTag(String tag) {
        if (this.tags_ == null) {
            tags_ = new ArrayList<>();
        }
        this.tags_.add(tag);
        return (T) this;
    }
630446
public function map(Closure $func)
    {
        $this->guardAgainstInvalidGivenType();
        $elements = $this->collection->map($func)->toArray();
        $newCollection = $this->create();
        foreach ($elements as $key => $element) {
            try {
                $newCollection->set($key, $element);
            } catch (InvalidArgumentException $e) {
                // do nothing, because the mapped item is not instance of type
            }
        }

        return $newCollection;
    }
370680
def add_tag(
            self,
            tag):
        

        if tag.replace("@", "") in self.tags:
            return

        self.refresh
        oldContent = self.to_string(indentLevel=1)
        self.tags += [tag.replace("@", "")]
        newContent = self.to_string(indentLevel=1)

        # ADD DIRECTLY TO CONTENT IF THE PROJECT IS BEING ADDED SPECIFICALLY TO
        # THIS OBJECT
        self.parent._update_document_tree(
            oldContent=oldContent,
            newContent=newContent
        )

        self.refresh
        return None
388055
public function checkTemplate($template, Tag $tag = null)
	{
		if ($this->disabled)
		{
			return;
		}

		if (!isset($tag))
		{
			$tag = new Tag;
		}

		// Load the template into a DOMDocument
		$dom = TemplateLoader::load($template);

		foreach ($this->collection as $check)
		{
			$check->check($dom->documentElement, $tag);
		}
	}
1157601
public function add_tag($tag, $message = null) {
		if ($message === null) {
			$message = $tag;
		}
		return $this->run("tag -a $tag -m " . escapeshellarg($message));
	}