src/mako/view/compilers/Template.php
protected function echos(string $template): string
	{
		// Closure that matches the "empty else" syntax

		$emptyElse = function($matches)
		{
			if(preg_match('/(.*)((\|\|)|(\s+or\s+))(.+)/', $matches) !== 0)
			{
				return preg_replace_callback('/(.*)((\|\|)|(\s+or\s+))(.+)/', function($matches)
				{
					return '(empty(' . trim($matches[1]) . ') ? ' . trim($matches[5]) . ' : ' . trim($matches[1]) . ')';
				}, $matches);
			}

			return $matches;
		};

		// Compiles echo tags

		return preg_replace_callback('/{{\s*(.*?)\s*}}/', function($matches) use ($emptyElse)
		{
			if(preg_match('/raw\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo %s; ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/preserve\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeHTML(%s, $__charset__, false); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/attribute\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeAttribute(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/js\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeJavascript(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/css\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeCSS(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/url\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeURL(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			else
			{
				return sprintf('<?php echo $this->escapeHTML(%s, $__charset__); ?>', $emptyElse($matches[1]));
			}
		}, $template);
	}
protected function echos(string $template): string
	{
		// Closure that matches the "empty else" syntax

		$emptyElse = function($matches)
		{
			if(preg_match('/(.*)((\|\|)|(\s+or\s+))(.+)/', $matches) !== 0)
			{
				return preg_replace_callback('/(.*)((\|\|)|(\s+or\s+))(.+)/', function($matches)
				{
					return '(empty(' . trim($matches[1]) . ') ? ' . trim($matches[5]) . ' : ' . trim($matches[1]) . ')';
				}, $matches);
			}

			return $matches;
		};

		// Compiles echo tags

		return preg_replace_callback('/{{\s*(.*?)\s*}}/', function($matches) use ($emptyElse)
		{
			if(preg_match('/raw\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo %s; ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/preserve\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeHTML(%s, $__charset__, false); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/attribute\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeAttribute(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/js\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeJavascript(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/css\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeCSS(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			elseif(preg_match('/url\s*:(.*)/i', $matches[1]) > 0)
			{
				return sprintf('<?php echo $this->escapeURL(%s, $__charset__); ?>', $emptyElse(substr($matches[1], strpos($matches[1], ':') + 1)));
			}
			else
			{
				return sprintf('<?php echo $this->escapeHTML(%s, $__charset__); ?>', $emptyElse($matches[1]));
			}
		}, $template);
	}
protected function echos ( string $ template ) : string { // Closure that matches the "empty else" syntax $ emptyElse = function ( $ matches ) { if ( preg_match ( '/(.*)((\|\|)|(\s+or\s+))(.+)/' , $ matches ) !== 0 ) { return preg_replace_callback ( '/(.*)((\|\|)|(\s+or\s+))(.+)/' , function ( $ matches ) { return '(empty(' . trim ( $ matches [ 1 ] ) . ') ? ' . trim ( $ matches [ 5 ] ) . ' : ' . trim ( $ matches [ 1 ] ) . ')' ; } , $ matches ) ; } return $ matches ; } ; // Compiles echo tags return preg_replace_callback ( '/{{\s*(.*?)\s*}}/' , function ( $ matches ) use ( $ emptyElse ) { if ( preg_match ( '/raw\s*:(.*)/i' , $ matches [ 1 ] ) > 0 ) { return sprintf ( '<?php echo %s; ?>' , $ emptyElse ( substr ( $ matches [ 1 ] , strpos ( $ matches [ 1 ] , ':' ) + 1 ) ) ) ; } elseif ( preg_match ( '/preserve\s*:(.*)/i' , $ matches [ 1 ] ) > 0 ) { return sprintf ( '<?php echo $this->escapeHTML(%s, $__charset__, false); ?>' , $ emptyElse ( substr ( $ matches [ 1 ] , strpos ( $ matches [ 1 ] , ':' ) + 1 ) ) ) ; } elseif ( preg_match ( '/attribute\s*:(.*)/i' , $ matches [ 1 ] ) > 0 ) { return sprintf ( '<?php echo $this->escapeAttribute(%s, $__charset__); ?>' , $ emptyElse ( substr ( $ matches [ 1 ] , strpos ( $ matches [ 1 ] , ':' ) + 1 ) ) ) ; } elseif ( preg_match ( '/js\s*:(.*)/i' , $ matches [ 1 ] ) > 0 ) { return sprintf ( '<?php echo $this->escapeJavascript(%s, $__charset__); ?>' , $ emptyElse ( substr ( $ matches [ 1 ] , strpos ( $ matches [ 1 ] , ':' ) + 1 ) ) ) ; } elseif ( preg_match ( '/css\s*:(.*)/i' , $ matches [ 1 ] ) > 0 ) { return sprintf ( '<?php echo $this->escapeCSS(%s, $__charset__); ?>' , $ emptyElse ( substr ( $ matches [ 1 ] , strpos ( $ matches [ 1 ] , ':' ) + 1 ) ) ) ; } elseif ( preg_match ( '/url\s*:(.*)/i' , $ matches [ 1 ] ) > 0 ) { return sprintf ( '<?php echo $this->escapeURL(%s, $__charset__); ?>' , $ emptyElse ( substr ( $ matches [ 1 ] , strpos ( $ matches [ 1 ] , ':' ) + 1 ) ) ) ; } else { return sprintf ( '<?php echo $this->escapeHTML(%s, $__charset__); ?>' , $ emptyElse ( $ matches [ 1 ] ) ) ; } } , $ template ) ; }
Compiles echos.

@param  string $template Template
@return string
Compiles echos .