Permalink
Browse files

CHtml::$closeSingleTags and CHtml::$renderSpecAttrVal added

  • Loading branch information...
1 parent 4687436 commit 1487995caed57501ef82957b4c3f6574a59c7e18 @creocoder creocoder committed Oct 2, 2012
Showing with 18 additions and 3 deletions.
  1. +2 −0 CHANGELOG
  2. +16 −3 framework/web/helpers/CHtml.php
View
@@ -55,6 +55,8 @@ Version 1.1.13 work in progress
- Enh: Value of the CHtml::activeTextArea() can now be set through $htmlOptions['value'] (resurtm)
- Enh: Allow to customize CHtml::error() container tag (creocoder)
- Enh: CModule::setComponents() now can reconfigure already loaded components (creocoder)
+- Enh: Allow to configure CHtml::$closeSingleTags. Useful for HTML5 code (creocoder)
+- Enh: Allow to configure CHtml::$renderSpecAttrVal. Useful for HTML5 code (creocoder)
- Chg: MSSQL unit tests updated and actualized, added SQLSRV driver support (resurtm)
- Chg: Added Oracle unit tests (resurtm)
- Chg: Updated CHttpCacheFilter to use dates as specified by RFC 1123 (bramp)
@@ -74,7 +74,16 @@ 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.
+ * @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.
+ */
+ public static $renderSpecAttrVal=true;
/**
* Encodes special characters into HTML entities.
@@ -142,7 +151,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 +2264,11 @@ public static function renderAttributes($htmlOptions)
if(isset($specialAttributes[$name]))
{
if($value)
- $html .= ' ' . $name . '="' . $name . '"';
+ {
+ $html .= ' ' . $name;
+ if(self::$renderSpecAttrVal)
+ $html .= '="' . $name . '"';
+ }
}
else if($value!==null)
$html .= ' ' . $name . '="' . ($raw ? $value : self::encode($value)) . '"';

0 comments on commit 1487995

Please sign in to comment.