diff options
author | Eric Barnes <eric@ericlbarnes.com> | 2012-07-29 19:17:50 +0200 |
---|---|---|
committer | Eric Barnes <eric@ericlbarnes.com> | 2012-07-29 19:17:50 +0200 |
commit | b01b4f5507523155a598d4ee03d2709a275e88cf (patch) | |
tree | cfe86860d3af5ead77bacda9794a4aad7f8925f1 /system/helpers/html_helper.php | |
parent | d83e727d6deedded5b637e685accb4fac0dc3985 (diff) | |
parent | 49d2f304d4bb9c04c41c34f4675813b9d8ac3204 (diff) |
Merge pull request #1669 from EllisLab/feature/stringify_attributes
Feature/stringify attributes
Diffstat (limited to 'system/helpers/html_helper.php')
-rw-r--r-- | system/helpers/html_helper.php | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 6fabf9c05..9843e804e 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -51,7 +51,7 @@ if ( ! function_exists('heading')) */ function heading($data = '', $h = '1', $attributes = '') { - return '<h'.$h.($attributes !== '' ? ' ' : '').$attributes.'>'.$data.'</h'.$h.'>'; + return '<h'.$h._stringify_attributes($attributes).'>'.$data.'</h'.$h.'>'; } } @@ -119,23 +119,8 @@ if ( ! function_exists('_list')) // Set the indentation based on the depth $out = str_repeat(' ', $depth); - // Were any attributes submitted? If so generate a string - if (is_array($attributes)) - { - $atts = ''; - foreach ($attributes as $key => $val) - { - $atts .= ' '.$key.'="'.$val.'"'; - } - $attributes = $atts; - } - elseif (is_string($attributes) && strlen($attributes) > 0) - { - $attributes = ' '.$attributes; - } - // Write the opening list tag - $out .= '<'.$type.$attributes.">\n"; + $out .= '<'.$type._stringify_attributes($attributes).">\n"; // Cycle through the list elements. If an array is // encountered we will recursively call _list() @@ -191,9 +176,10 @@ if ( ! function_exists('img')) * * @param mixed * @param bool + * @param mixed * @return string */ - function img($src = '', $index_page = FALSE) + function img($src = '', $index_page = FALSE, $attributes = '') { if ( ! is_array($src) ) { @@ -229,7 +215,7 @@ if ( ! function_exists('img')) } } - return $img.'/>'; + return $img._stringify_attributes($attributes).'/>'; } } |