summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Adam <sebastien.adam.webdev@gmail.com>2015-12-01 20:02:07 +0100
committerSébastien Adam <sebastien.adam.webdev@gmail.com>2015-12-01 20:02:07 +0100
commit6ab09773d96ce6ac672a3d852256126d10aa25d8 (patch)
tree6b068464f44bf72064a4df8731d7aa44bd4c91e1
parentdfcc5318d378ae66dd21806c6ac2dad67d73dc26 (diff)
Modified as asked after pull request:
* comment of meta fuction adapted * alignments in meta fuction adapted * using '===' comparator in meta function * changing back the example of the meta function help * changing back the default value of the doctype function Also changing test unit to reflect the modification of the meta function (original tests not modified).
-rw-r--r--system/helpers/html_helper.php14
-rw-r--r--tests/codeigniter/helpers/html_helper_test.php6
-rw-r--r--user_guide_src/source/helpers/html_helper.rst4
3 files changed, 14 insertions, 10 deletions
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index b4c605a01..36680053a 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -229,7 +229,7 @@ if ( ! function_exists('doctype'))
* @param string type The doctype to be generated
* @return string
*/
- function doctype($type = 'html5')
+ function doctype($type = 'xhtml1-strict')
{
static $doctypes;
@@ -363,13 +363,13 @@ if ( ! function_exists('meta'))
$str = '';
foreach ($name as $meta)
{
- $meta['type'] = (isset($meta['type']) && ($meta['type'] == 'equiv')) ? 'http-equiv' : $meta['type']; // backward compatibility
- $type = (isset($meta['type']) && in_array($meta['type'], $allowed_type))? $meta['type'] : 'name';
- $name = isset($meta['name']) ? $meta['name'] : '';
- $content = (isset($meta['content']) && $type != 'charset') ? $meta['content'] : '';
- $newline = isset($meta['newline']) ? $meta['newline'] : "\n";
+ $meta['type'] = isset($meta['type']) ? (($meta['type'] === 'equiv') ? 'http-equiv' : $meta['type']) : ''; // backward compatibility
+ $type = in_array($meta['type'], $allowed_type) ? $meta['type'] : 'name';
+ $name = isset($meta['name']) ? $meta['name'] : '';
+ $content = isset($meta['content']) ? $meta['content'] : '';
+ $newline = isset($meta['newline']) ? $meta['newline'] : "\n";
- $str .= '<meta '.$type.'="'.$name.'" content="'.$content.'" />'.$newline;
+ $str .= '<meta '.$type.'="'.$name.(($type === 'charset')?'':'" content="'.$content).'" />'.$newline;
}
return $str;
diff --git a/tests/codeigniter/helpers/html_helper_test.php b/tests/codeigniter/helpers/html_helper_test.php
index d66ad895c..0b9655bf5 100644
--- a/tests/codeigniter/helpers/html_helper_test.php
+++ b/tests/codeigniter/helpers/html_helper_test.php
@@ -87,6 +87,10 @@ EOH;
$this->assertEquals($expect, meta(array('name' => 'foo')));
+ $expect = "<meta charset=\"foo\" />\n";
+
+ $this->assertEquals($expect, meta(array('name' => 'foo', 'type' => 'charset')));
+
}
-} \ No newline at end of file
+}
diff --git a/user_guide_src/source/helpers/html_helper.rst b/user_guide_src/source/helpers/html_helper.rst
index bfd4afbe2..fffb2cab4 100644
--- a/user_guide_src/source/helpers/html_helper.rst
+++ b/user_guide_src/source/helpers/html_helper.rst
@@ -285,9 +285,9 @@ The following functions are available:
echo meta('description', 'My Great site');
// Generates: <meta name="description" content="My Great Site" />
- echo meta('refresh', '30', 'http-equiv');
+ echo meta('Content-type', 'text/html; charset=utf-8', 'equiv');
// Note the third parameter. Can be "charset", "http-equiv", "name" or "property"
- // Generates: <meta http-equiv="refresh" content="30" />
+ // Generates: <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
echo meta(array('name' => 'robots', 'content' => 'no-cache'));
// Generates: <meta name="robots" content="no-cache" />