Railsbin – The vulnerable pastebin service!

User:

Title: WithPHPJQuery

Content:

<?php
namespace GDO\UI;

/**
 * Should be extended to reflect a jQuery API on php objects.
 * 
 * @author gizmore
 * @since 6.07
 */
trait WithPHPJQuery
{
	#######################
	### HTML Attributes ###
	#######################
	public $htmlAttributes;
	public function attr($attribute, $value)
	{
		if (!$this->htmlAttributes)
		{
			$this->htmlAttributes = [];
		}
		$this->htmlAttributes[$attribute] = $value;
		return $this;
	}
	
	public function htmlAttributes()
	{
		$html = '';
		foreach ($this->htmlAttributes as $attribute => $value)
		{
			$html .= " $attribute=\"$value\"";
		}
		return $html;
	}

}

Edit | Back