Merge pull request #1210 from franzliedke/patch-44
Definition list support (#1202)
This commit is contained in:
commit
0dc124d342
|
@ -119,6 +119,8 @@ #### Creating lists from an array of items:
|
||||||
echo HTML::ol(array('Get Peanut Butter', 'Get Chocolate', 'Feast'));
|
echo HTML::ol(array('Get Peanut Butter', 'Get Chocolate', 'Feast'));
|
||||||
|
|
||||||
echo HTML::ul(array('Ubuntu', 'Snow Leopard', 'Windows'));
|
echo HTML::ul(array('Ubuntu', 'Snow Leopard', 'Windows'));
|
||||||
|
|
||||||
|
echo HTML::dl(array('Ubuntu' => 'An operating system by Canonical', 'Windows' => 'An operating system by Microsoft'));
|
||||||
|
|
||||||
<a name="custom-macros"></a>
|
<a name="custom-macros"></a>
|
||||||
## Custom Macros
|
## Custom Macros
|
||||||
|
|
|
@ -347,6 +347,28 @@ private static function listing($type, $list, $attributes = array())
|
||||||
|
|
||||||
return '<'.$type.static::attributes($attributes).'>'.$html.'</'.$type.'>';
|
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.'</dl>';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a list of HTML attributes from an array.
|
* Build a list of HTML attributes from an array.
|
||||||
|
|
Loading…
Reference in New Issue