Skip to content

Commit 0dc124d

Browse files
committed
Merge pull request laravel#1210 from franzliedke/patch-44
Definition list support (#1202)
2 parents 99d710a + 65d4b24 commit 0dc124d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

laravel/documentation/views/html.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ The "mailto" method on the HTML class obfuscates the given e-mail address so it
119119
echo HTML::ol(array('Get Peanut Butter', 'Get Chocolate', 'Feast'));
120120

121121
echo HTML::ul(array('Ubuntu', 'Snow Leopard', 'Windows'));
122+
123+
echo HTML::dl(array('Ubuntu' => 'An operating system by Canonical', 'Windows' => 'An operating system by Microsoft'));
122124

123125
<a name="custom-macros"></a>
124126
## Custom Macros

laravel/html.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,28 @@ private static function listing($type, $list, $attributes = array())
347347

348348
return '<'.$type.static::attributes($attributes).'>'.$html.'</'.$type.'>';
349349
}
350+
351+
/**
352+
* Generate a definition list.
353+
*
354+
* @param array $list
355+
* @param array $attributes
356+
* @return string
357+
*/
358+
public static function dl($list, $attributes = array())
359+
{
360+
$html = '';
361+
362+
if (count($list) == 0) return $html;
363+
364+
foreach ($list as $term => $description)
365+
{
366+
$html .= '<dt>'.static::entities($term).'</dt>';
367+
$html .= '<dd>'.static::entities($description).'</dd>';
368+
}
369+
370+
return '<dl'.static::attributes($attributes).'>'.$html.'</dl>';
371+
}
350372

351373
/**
352374
* Build a list of HTML attributes from an array.

0 commit comments

Comments
 (0)