protected static function replaceTokensInAttribute(DOMAttr $attribute, $regexp, $fn)
	{
		$attrValue = preg_replace_callback(
			$regexp,
			function ($m) use ($fn, $attribute)
			{
				$replacement = $fn($m, $attribute);
				if ($replacement[0] === 'expression' || $replacement[0] === 'passthrough')
				{
					// Use the node's text content as the default expression
					$replacement[] = '.';

					return '{' . $replacement[1] . '}';
				}
				else
				{
					return $replacement[1];
				}
			},
			$attribute->value
		);
		$attribute->value = htmlspecialchars($attrValue, ENT_COMPAT, 'UTF-8');
	}
protected static function replaceTokensInAttribute(DOMAttr $attribute, $regexp, $fn)
	{
		$attrValue = preg_replace_callback(
			$regexp,
			function ($m) use ($fn, $attribute)
			{
				$replacement = $fn($m, $attribute);
				if ($replacement[0] === 'expression' || $replacement[0] === 'passthrough')
				{
					// Use the node's text content as the default expression
					$replacement[] = '.';

					return '{' . $replacement[1] . '}';
				}
				else
				{
					return $replacement[1];
				}
			},
			$attribute->value
		);
		$attribute->value = htmlspecialchars($attrValue, ENT_COMPAT, 'UTF-8');
	}
protected static function replaceTokensInAttribute ( DOMAttr $ attribute , $ regexp , $ fn ) { $ attrValue = preg_replace_callback ( $ regexp , function ( $ m ) use ( $ fn , $ attribute ) { $ replacement = $ fn ( $ m , $ attribute ) ; if ( $ replacement [ 0 ] === 'expression' || $ replacement [ 0 ] === 'passthrough' ) { // Use the node's text content as the default expression $ replacement [ ] = '.' ; return '{' . $ replacement [ 1 ] . '}' ; } else { return $ replacement [ 1 ] ; } } , $ attribute -> value ) ; $ attribute -> value = htmlspecialchars ( $ attrValue , ENT_COMPAT , 'UTF-8' ) ; }
Replace parts of an attribute that match given regexp

@param  DOMAttr  $attribute Attribute
@param  string   $regexp    Regexp for matching parts that need replacement
@param  callback $fn        Callback used to get the replacement
@return void
Replace parts of an attribute that match given regexp