<commit_before><?php

namespace mako;

/**
* HTML helper.
*
* @author     <NAME>
* @copyright  (c) 2008-2011 <NAME>
* @license    http://www.makoframework.com/license
*/

class HTML
{
	//---------------------------------------------
	// Class variables
	//---------------------------------------------

	// Nothing here

	//---------------------------------------------
	// Class constructor, destructor etc ...
	//---------------------------------------------

	/**
	* Protected constructor since this is a static class.
	*
	* @access  protected
	*/

	protected function __construct()
	{
		// Nothing here
	}

	//---------------------------------------------
	// Class methods
	//---------------------------------------------


	/**
	* Takes an array of attributes and turns it into a string.
	*
	* @access  public
	* @param   array   Array of tags
	* @return  string
	*/

	protected static function attributes($attributes)
	{
		$attr = '';
		
		foreach($attributes as $attribute => $value)
		{
			if(is_int($attribute))
			{
				$attribute = $value;
			}
			
			$attr .= ' ' . $attribute . '="' . $value . '"';
		}

		return $attr;
	}

	/**
	* Creates a HTML5 tag.
	*
	* @access  public
	* @param   string  Tag name
	* @param   array   (optional) Tag attributes
	* @param   string  (optional) Tag content
	* @return  string
	*/

	public static function tag($name, array $attributes = array(), $content = null)
	{
		return '<' . $name . static::attributes($attributes) . (($content === null) ? (defined('MAKO_XHTML') ? '/>' : '>') : '>' . $content . '</' . $name . '>');
	}

	/**
	* Helper method for building media tags.
	*
	* @access  protected
	* @param   string     Tag type
	* @param   mixed      File or array of files
	* @param   array      (optional) Tag attributes
	*/

	protected static function buildMedia($type, $files, $attributes)
	{
		$sources = '';

		foreach((array) $files as $file)
		{
			$sources .= HTML::tag('source', array('src' => $file));
		}
		
		return static::tag($type, $attributes, $sources);
	}

	/**
	* Creates audio tag with support for multiple sources.
	*
	* @access  public
	* @param   mixed   File or array of files
	* @param   array   (optional) Tag attributes
	*/

	public static function audio($files, array $attributes = array())
	{
		return static::buildMedia('audio', $files, $attributes);
	}

	/**
	* Creates video tag with support for multiple sources.
	*
	* @access  public
	* @param   mixed   File or array of files
	* @param   array   (optional) Tag attributes
	*/

	public static function video($files, array $attributes = array())
	{
		return static::buildMedia('video', $files, $attributes);
	}

	/**
	* Helper method for building list tags.
	*
	* @access  protected
	* @param   string     Tag type
	* @param   mixed      File or array of files
	* @param   array      (optional) Tag attributes
	*/

	protected static function buildList($type, $items, $attributes)
	{
		$list = '';

		foreach($items as $item)
		{
			if(is_array($item))
			{
				$list .= static::tag('li', array(), static::buildList($type, $item, array()));
			}
			else
			{
				$list .= static::tag('li', array(), $item);
			}
		}

		return static::tag($type, $attributes, $list);
	}

	/**
	* Builds an un-ordered list.
	*
	* @access  public
	* @param   array   List items
	* @param   array   List attributes
	* @return  string
	*/

	public static function ul(array $items, array $attributes = array())
	{
		return static::buildList('ul', $items, $attributes);
	}

	/**
	* Builds am ordered list.
	*
	* @access  public
	* @param   array   List items
	* @param   array   List attributes
	* @return  string
	*/

	public static function ol(array $items, array $attributes = array())
	{
		return static::buildList('ol', $items, $attributes);
	}
}

/** -------------------- End of file --------------------**/<commit_msg>Now possible to add custom HTML macros<commit_after><?php

namespace mako;

use \Closure;
use \RuntimeException;

/**
* HTML helper.
*
* @author     <NAME>
* @copyright  (c) 2008-2011 <NAME>
* @license    http://www.makoframework.com/license
*/

class HTML
{
	//---------------------------------------------
	// Class variables
	//---------------------------------------------

	/**
	* Custom macros.
	*
	* @var array
	*/

	protected static $macros = array();

	//---------------------------------------------
	// Class constructor, destructor etc ...
	//---------------------------------------------

	/**
	* Protected constructor since this is a static class.
	*
	* @access  protected
	*/

	protected function __construct()
	{
		// Nothing here
	}

	//---------------------------------------------
	// Class methods
	//---------------------------------------------


	/**
	* Takes an array of attributes and turns it into a string.
	*
	* @access  public
	* @param   array   Array of tags
	* @return  string
	*/

	protected static function attributes($attributes)
	{
		$attr = '';
		
		foreach($attributes as $attribute => $value)
		{
			if(is_int($attribute))
			{
				$attribute = $value;
			}
			
			$attr .= ' ' . $attribute . '="' . $value . '"';
		}

		return $attr;
	}

	/**
	* Creates a HTML5 tag.
	*
	* @access  public
	* @param   string  Tag name
	* @param   array   (optional) Tag attributes
	* @param   string  (optional) Tag content
	* @return  string
	*/

	public static function tag($name, array $attributes = array(), $content = null)
	{
		return '<' . $name . static::attributes($attributes) . (($content === null) ? (defined('MAKO_XHTML') ? '/>' : '>') : '>' . $content . '</' . $name . '>');
	}

	/**
	* Helper method for building media tags.
	*
	* @access  protected
	* @param   string     Tag type
	* @param   mixed      File or array of files
	* @param   array      (optional) Tag attributes
	*/

	protected static function buildMedia($type, $files, $attributes)
	{
		$sources = '';

		foreach((array) $files as $file)
		{
			$sources .= HTML::tag('source', array('src' => $file));
		}
		
		return static::tag($type, $attributes, $sources);
	}

	/**
	* Creates audio tag with support for multiple sources.
	*
	* @access  public
	* @param   mixed   File or array of files
	* @param   array   (optional) Tag attributes
	*/

	public static function audio($files, array $attributes = array())
	{
		return static::buildMedia('audio', $files, $attributes);
	}

	/**
	* Creates video tag with support for multiple sources.
	*
	* @access  public
	* @param   mixed   File or array of files
	* @param   array   (optional) Tag attributes
	*/

	public static function video($files, array $attributes = array())
	{
		return static::buildMedia('video', $files, $attributes);
	}

	/**
	* Helper method for building list tags.
	*
	* @access  protected
	* @param   string     Tag type
	* @param   mixed      File or array of files
	* @param   array      (optional) Tag attributes
	*/

	protected static function buildList($type, $items, $attributes)
	{
		$list = '';

		foreach($items as $item)
		{
			if(is_array($item))
			{
				$list .= static::tag('li', array(), static::buildList($type, $item, array()));
			}
			else
			{
				$list .= static::tag('li', array(), $item);
			}
		}

		return static::tag($type, $attributes, $list);
	}

	/**
	* Builds an un-ordered list.
	*
	* @access  public
	* @param   array   List items
	* @param   array   List attributes
	* @return  string
	*/

	public static function ul(array $items, array $attributes = array())
	{
		return static::buildList('ul', $items, $attributes);
	}

	/**
	* Builds am ordered list.
	*
	* @access  public
	* @param   array   List items
	* @param   array   List attributes
	* @return  string
	*/

	public static function ol(array $items, array $attributes = array())
	{
		return static::buildList('ol', $items, $attributes);
	}

	/**
	*
	*/

	public static function macro($name, Closure $macro)
	{
		static::$macros[$name] = $macro;
	}

	/**
	*
	*/

	public static function __callStatic($name, $arguments)
	{
		if(!isset(static::$macros[$name]))
		{
			throw new RuntimeException(vsprintf("Call to undefined method %s::%s().", array(__CLASS__, $name)));
		}

		return call_user_func_array(static::$macros[$name], $arguments);
	}
}

/** -------------------- End of file --------------------**/
{'fraction_non_alphanumeric': 0.22082672844775028, 'fraction_numerical': 0.0021948542860626753, 'mean_word_length': 2.201405152224824, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1967485', 'n_tokens_mistral': 2722, 'n_tokens_neox': 2518, 'n_words': 710}