From c7763a23bd7f43f8837ac7077664931518ce8e3b Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 12 Sep 2012 14:40:55 +0300 Subject: [PATCH 1/3] Add definition list helper to HTML class. --- laravel/html.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/laravel/html.php b/laravel/html.php index fd5bf82e..e3b2a993 100644 --- a/laravel/html.php +++ b/laravel/html.php @@ -347,6 +347,28 @@ private static function listing($type, $list, $attributes = array()) return '<'.$type.static::attributes($attributes).'>'.$html.''; } + + /** + * 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 .= '
'.static::entities($term).'
'; + $html .= '
'.static::entities($description).'
'; + } + + return ''.$html.''; + } /** * Build a list of HTML attributes from an array. From 5942771ce9bd69d46ce2b84ac683681c322a776e Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 12 Sep 2012 14:42:20 +0300 Subject: [PATCH 2/3] Add documentation for definition list helper. --- laravel/documentation/views/html.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/laravel/documentation/views/html.md b/laravel/documentation/views/html.md index 5bcaa389..aabe244d 100644 --- a/laravel/documentation/views/html.md +++ b/laravel/documentation/views/html.md @@ -119,6 +119,8 @@ #### Creating lists from an array of items: echo HTML::ol(array('Get Peanut Butter', 'Get Chocolate', 'Feast')); echo HTML::ul(array('Ubuntu', 'Snow Leopard', 'Windows')); + + echo HTML::dl(array('Ubuntu' => 'An operating system by Canonical', 'Windows' => 'An operating system by Microsoft')); ## Custom Macros From 65d4b2448ba43fdfa61769a770786c1c47a43780 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Fri, 14 Sep 2012 22:21:35 +0300 Subject: [PATCH 3/3] Fix closing tag in definition list helper. --- laravel/html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/html.php b/laravel/html.php index e3b2a993..211e4022 100644 --- a/laravel/html.php +++ b/laravel/html.php @@ -367,7 +367,7 @@ public static function dl($list, $attributes = array()) $html .= '
'.static::entities($description).'
'; } - return ''.$html.''; + return ''.$html.''; } /**