Browse Source

Add definition list helper to HTML class.

Franz Liedke 12 years ago
parent
commit
c7763a23bd
1 changed files with 22 additions and 0 deletions
  1. 22 0
      laravel/html.php

+ 22 - 0
laravel/html.php

@@ -347,6 +347,28 @@ class HTML {
 
 		return '<'.$type.static::attributes($attributes).'>'.$html.'</'.$type.'>';
 	}
+	
+	/**
+	 * Generate a definition list.
+	 *
+	 * @param  array   $list
+	 * @param  array   $attributes
+	 * @return string
+	 */
+	public static function dl($list, $attributes = array())
+	{
+		$html = '';
+
+		if (count($list) == 0) return $html;
+		
+		foreach ($list as $term => $description)
+		{
+			$html .= '<dt>'.static::entities($term).'</dt>';
+			$html .= '<dd>'.static::entities($description).'</dd>';
+		}
+		
+		return '<dl'.static::attributes($attributes).'>'.$html.'</'.$type.'>';
+	}
 
 	/**
 	 * Build a list of HTML attributes from an array.