protected function convertTemplate($template, $passthroughIdx)
	{
		// Replace numeric references in the template with the value of the corresponding attribute
		// values or passthrough
		$template = TemplateModifier::replaceTokens(
			$template,
			$this->referencesRegexp,
			function ($m, $node) use ($passthroughIdx)
			{
				$key = (int) trim($m[0], '\\${}');
				if ($key === 0)
				{
					// $0 copies the whole textContent
					return ['expression', '.'];
				}
				if ($key === $passthroughIdx && $node instanceof DOMText)
				{
					// Passthrough capture, does not include start/end tags
					return ['passthrough'];
				}
				if (isset($this->captures[$key]['name']))
				{
					// Normal capture, replaced by the equivalent expression
					return ['expression', '@' . $this->captures[$key]['name']];
				}

				// Non-existent captures are simply ignored, similarly to preg_replace()
				return ['literal', ''];
			}
		);

		// Unescape backslashes and special characters in the template
		$template = TemplateModifier::replaceTokens(
			$template,
			'(\\\\+[0-9${\\\\])',
			function ($m)
			{
				return ['literal', stripslashes($m[0])];
			}
		);

		return $template;
	}
protected function convertTemplate($template, $passthroughIdx)
	{
		// Replace numeric references in the template with the value of the corresponding attribute
		// values or passthrough
		$template = TemplateModifier::replaceTokens(
			$template,
			$this->referencesRegexp,
			function ($m, $node) use ($passthroughIdx)
			{
				$key = (int) trim($m[0], '\\${}');
				if ($key === 0)
				{
					// $0 copies the whole textContent
					return ['expression', '.'];
				}
				if ($key === $passthroughIdx && $node instanceof DOMText)
				{
					// Passthrough capture, does not include start/end tags
					return ['passthrough'];
				}
				if (isset($this->captures[$key]['name']))
				{
					// Normal capture, replaced by the equivalent expression
					return ['expression', '@' . $this->captures[$key]['name']];
				}

				// Non-existent captures are simply ignored, similarly to preg_replace()
				return ['literal', ''];
			}
		);

		// Unescape backslashes and special characters in the template
		$template = TemplateModifier::replaceTokens(
			$template,
			'(\\\\+[0-9${\\\\])',
			function ($m)
			{
				return ['literal', stripslashes($m[0])];
			}
		);

		return $template;
	}
protected function convertTemplate ( $ template , $ passthroughIdx ) { // Replace numeric references in the template with the value of the corresponding attribute // values or passthrough $ template = TemplateModifier :: replaceTokens ( $ template , $ this -> referencesRegexp , function ( $ m , $ node ) use ( $ passthroughIdx ) { $ key = ( int ) trim ( $ m [ 0 ] , '\\${}' ) ; if ( $ key === 0 ) { // $0 copies the whole textContent return [ 'expression' , '.' ] ; } if ( $ key === $ passthroughIdx && $ node instanceof DOMText ) { // Passthrough capture, does not include start/end tags return [ 'passthrough' ] ; } if ( isset ( $ this -> captures [ $ key ] [ 'name' ] ) ) { // Normal capture, replaced by the equivalent expression return [ 'expression' , '@' . $ this -> captures [ $ key ] [ 'name' ] ] ; } // Non-existent captures are simply ignored, similarly to preg_replace() return [ 'literal' , '' ] ; } ) ; // Unescape backslashes and special characters in the template $ template = TemplateModifier :: replaceTokens ( $ template , '(\\\\+[0-9${\\\\])' , function ( $ m ) { return [ 'literal' , stripslashes ( $ m [ 0 ] ) ] ; } ) ; return $ template ; }
Convert a preg-style replacement to a template

@param  string  $template       Original template
@param  integer $passthroughIdx Index of the passthrough capture
@return string                  Modified template
Convert a preg - style replacement to a template