summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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" />