Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 1487995caed57501ef82957b4c3f6574a59c7e18 1 parent 4687436
Alexander Kochetov authored October 02, 2012
2  CHANGELOG
@@ -55,6 +55,8 @@ Version 1.1.13 work in progress
55 55
 - Enh: Value of the CHtml::activeTextArea() can now be set through $htmlOptions['value'] (resurtm)
56 56
 - Enh: Allow to customize CHtml::error() container tag (creocoder)
57 57
 - Enh: CModule::setComponents() now can reconfigure already loaded components (creocoder)
  58
+- Enh: Allow to configure CHtml::$closeSingleTags. Useful for HTML5 code (creocoder)
  59
+- Enh: Allow to configure CHtml::$renderSpecAttrVal. Useful for HTML5 code (creocoder)
58 60
 - Chg: MSSQL unit tests updated and actualized, added SQLSRV driver support (resurtm)
59 61
 - Chg: Added Oracle unit tests (resurtm)
60 62
 - Chg: Updated CHttpCacheFilter to use dates as specified by RFC 1123 (bramp)
19  framework/web/helpers/CHtml.php
@@ -74,7 +74,16 @@ class CHtml
74 74
 	 * @since 1.1.9
75 75
 	 * @see clientChange
76 76
 	 */
77  
-	public static $liveEvents = true;
  77
+	public static $liveEvents=true;
  78
+	/*
  79
+	 * @var boolean whether to close single tags. Defaults to true. Can be setted to false for HTML5.
  80
+	 * @since 1.1.13
  81
+	 */
  82
+	public static $closeSingleTags=true;
  83
+	/*
  84
+	 * @var boolean whether to render special attributes value. Defaults to true. Can be setted to false for HTML5.
  85
+	 */
  86
+	public static $renderSpecAttrVal=true;
78 87
 
79 88
 	/**
80 89
 	 * Encodes special characters into HTML entities.
@@ -142,7 +151,7 @@ public static function tag($tag,$htmlOptions=array(),$content=false,$closeTag=tr
142 151
 	{
143 152
 		$html='<' . $tag . self::renderAttributes($htmlOptions);
144 153
 		if($content===false)
145  
-			return $closeTag ? $html.' />' : $html.'>';
  154
+			return $closeTag && self::$closeSingleTags ? $html.' />' : $html.'>';
146 155
 		else
147 156
 			return $closeTag ? $html.'>'.$content.'</'.$tag.'>' : $html.'>'.$content;
148 157
 	}
@@ -2255,7 +2264,11 @@ public static function renderAttributes($htmlOptions)
2255 2264
 			if(isset($specialAttributes[$name]))
2256 2265
 			{
2257 2266
 				if($value)
2258  
-					$html .= ' ' . $name . '="' . $name . '"';
  2267
+				{
  2268
+					$html .= ' ' . $name;
  2269
+					if(self::$renderSpecAttrVal)
  2270
+						$html .= '="' . $name . '"';
  2271
+				}
2259 2272
 			}
2260 2273
 			else if($value!==null)
2261 2274
 				$html .= ' ' . $name . '="' . ($raw ? $value : self::encode($value)) . '"';

0 notes on commit 1487995

Please sign in to comment.
Something went wrong with that request. Please try again.