Skip to content

CHtml::$closeSingleTags and CHtml::$renderSpecialAttributesValue added #1518

Merged
merged 4 commits into from Oct 2, 2012
View
1 CHANGELOG
@@ -48,6 +48,7 @@ Version 1.1.13 work in progress
- Enh #1396: Added 'text/csv' mime-type for the 'csv' file extension in utils/mimeTypes.php (effectively used by e.g. CHttpRequest::sendFile()) (rawtaz)
- Enh #1426: Behaviors are now affecting memory consumption significantly less (slavcodev, creocoder, Qiang, samdark)
- Enh #1443: Added CHttpRequest::getRawBody() that allows reading RAW HTTP request body multiple times (itamar82, resurtm, samdark)
+- Enh #1518: Allow to configure CHtml::$closeSingleTags and CHtml::$renderSpecialAttributesValue. Useful for HTML5 code (creocoder)
- Enh: Fixed the check for ajaxUpdate false value in jquery.yiilistview.js as that never happens (mdomba)
- Enh: Requirements checker: added check for Oracle database (pdo_oci extension) and MSSQL (pdo_dblib, pdo_sqlsrv and pdo_mssql extensions) (resurtm)
- Enh: Added CChainedLogFilter class to allow adding multiple filters to a logroute (cebe)
View
20 framework/web/helpers/CHtml.php
@@ -74,7 +74,17 @@ class CHtml
* @since 1.1.9
* @see clientChange
*/
- public static $liveEvents = true;
+ public static $liveEvents=true;
+ /*
+ * @var boolean whether to close single tags. Defaults to true. Can be setted to false for HTML5.
@mdomba
Yii Software LLC member
mdomba added a note Oct 2, 2012

is it setted or set?

@cebe
Yii Software LLC member
cebe added a note Oct 2, 2012

has to be set. fixed in 0955e63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ * @since 1.1.13
+ */
+ public static $closeSingleTags=true;
+ /*
+ * @var boolean whether to render special attributes value. Defaults to true. Can be setted to false for HTML5.
+ * @since 1.1.13
+ */
+ public static $renderSpecialAttributesValue=true;
/**
* Encodes special characters into HTML entities.
@@ -142,7 +152,7 @@ public static function tag($tag,$htmlOptions=array(),$content=false,$closeTag=tr
{
$html='<' . $tag . self::renderAttributes($htmlOptions);
if($content===false)
- return $closeTag ? $html.' />' : $html.'>';
+ return $closeTag && self::$closeSingleTags ? $html.' />' : $html.'>';
else
return $closeTag ? $html.'>'.$content.'</'.$tag.'>' : $html.'>'.$content;
}
@@ -2255,7 +2265,11 @@ public static function renderAttributes($htmlOptions)
if(isset($specialAttributes[$name]))
{
if($value)
- $html .= ' ' . $name . '="' . $name . '"';
+ {
+ $html .= ' ' . $name;
+ if(self::$renderSpecialAttributesValue)
+ $html .= '="' . $name . '"';
+ }
}
else if($value!==null)
$html .= ' ' . $name . '="' . ($raw ? $value : self::encode($value)) . '"';
Something went wrong with that request. Please try again.