diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 14068a99b..997513d3f 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -465,12 +465,25 @@ abstract class Utils public static function getHtmlFromExcerpt($excerpt) { - // needs to be more flexible.. this is a rough pass for testing - $html = '<' . $excerpt['element']['name'] . ' '; - foreach ($excerpt['element']['attributes'] as $name => $value) { - $html .= $name . '="' . $value . '" '; + $element = $excerpt['element']; + $html = '<'.$element['name']; + + if (isset($element['attributes'])) { + foreach ($element['attributes'] as $name => $value) { + if ($value === null) { + continue; + } + $html .= ' '.$name.'="'.$value.'"'; + } + } + + if (isset($element['text'])) { + $html .= '>'; + $html .= $element['text']; + $html .= ''; + } else { + $html .= ' />'; } - $html .= '/>'; return $html; }