r96256 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96255‎ | r96256 | r96257 >
Date:21:18, 4 September 2011
Author:krinkle
Status:ok
Tags:
Comment:
Add documentation for r96170 and r96188.
Modified paths:
  • /trunk/phase3/includes/Html.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Html.php
@@ -105,7 +105,7 @@
106106 * Returns an HTML element in a string. The major advantage here over
107107 * manually typing out the HTML is that it will escape all attribute
108108 * values. If you're hardcoding all the attributes, or there are none, you
109 - * should probably type out the string yourself.
 109+ * should probably just type out the html element yourself.
110110 *
111111 * This is quite similar to Xml::tags(), but it implements some useful
112112 * HTML-specific logic. For instance, there is no $allowShortTag
@@ -115,7 +115,7 @@
116116 *
117117 * @param $element string The element's name, e.g., 'a'
118118 * @param $attribs array Associative array of attributes, e.g., array(
119 - * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for
 119+ * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for
120120 * further documentation.
121121 * @param $contents string The raw HTML contents of the element: *not*
122122 * escaped!
@@ -358,6 +358,26 @@
359359 * For instance, it will omit quotation marks if $wgWellFormedXml is false,
360360 * and will treat boolean attributes specially.
361361 *
 362+ * Attributes that should contain space-separated lists (such as 'class') array
 363+ * values are allowed as well, which will automagically be normalized
 364+ * and converted to a space-separated string. In addition to a numerical
 365+ * array, the attribute value may also be an associative array. See the
 366+ * example below for how that works.
 367+ * @example Numerical array
 368+ * <code>
 369+ * Html::element( 'em', array(
 370+ * 'class' => array( 'foo', 'bar' )
 371+ * ) );
 372+ * // gives '<em class="foo bar"></em>'
 373+ * </code>
 374+ * @example Associative array
 375+ * <code>
 376+ * Html::element( 'em', array(
 377+ * 'class' => array( 'foo', 'bar', 'foo' => false, 'quux' => true )
 378+ * ) );
 379+ * // gives '<em class="bar quux"></em>'
 380+ * </code>
 381+ *
362382 * @param $attribs array Associative array of attributes, e.g., array(
363383 * 'href' => 'http://www.mediawiki.org/' ). Values will be HTML-escaped.
364384 * A value of false means to omit the attribute. For boolean attributes,

Sign-offs

UserFlagDate
Simetricalinspected16:38, 5 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96170Html.php: The "future"[1] is here. Add features for space-separated value att...krinkle03:55, 3 September 2011
r96188Expand r96170's support for space separated attributes with support for boole...dantman14:36, 3 September 2011

Status & tagging log