summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/helpers/html_helper.php13
-rw-r--r--tests/codeigniter/helpers/html_helper_test.php6
-rw-r--r--user_guide_src/source/helpers/html_helper.rst16
3 files changed, 20 insertions, 15 deletions
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index fdc463fca..5cc994ff1 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -359,16 +359,17 @@ if ( ! function_exists('meta'))
// Turn single array into multidimensional
$name = array($name);
}
-
+ $allowed_type = array('charset', 'http-equiv', 'name', 'property');
$str = '';
foreach ($name as $meta)
{
- $type = (isset($meta['type']) && $meta['type'] !== 'name') ? 'http-equiv' : 'name';
- $name = isset($meta['name']) ? $meta['name'] : '';
- $content = isset($meta['content']) ? $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 2c748bea0..fffb2cab4 100644
--- a/user_guide_src/source/helpers/html_helper.rst
+++ b/user_guide_src/source/helpers/html_helper.rst
@@ -286,7 +286,7 @@ The following functions are available:
// Generates: <meta name="description" content="My Great Site" />
echo meta('Content-type', 'text/html; charset=utf-8', 'equiv');
- // Note the third parameter. Can be "equiv" or "name"
+ // Note the third parameter. Can be "charset", "http-equiv", "name" or "property"
// Generates: <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
echo meta(array('name' => 'robots', 'content' => 'no-cache'));
@@ -310,8 +310,8 @@ The following functions are available:
'content' => 'no-cache'
),
array(
- 'name' => 'Content-type',
- 'content' => 'text/html; charset=utf-8', 'type' => 'equiv'
+ 'name' => 'UTF-8',
+ 'type' => 'charset'
)
);
@@ -321,21 +321,21 @@ The following functions are available:
// <meta name="description" content="My Great Site" />
// <meta name="keywords" content="love, passion, intrigue, deception" />
// <meta name="robots" content="no-cache" />
- // <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ // <meta charset="UTF-8" />
-.. php:function:: doctype([$type = 'xhtml1-strict'])
+.. php:function:: doctype([$type = 'html5'])
:param string $type: Doctype name
:returns: HTML DocType tag
:rtype: string
- Helps you generate document type declarations, or DTD's. XHTML 1.0
- Strict is used by default, but many doctypes are available.
+ Helps you generate document type declarations, or DTD's. HTML 5
+ is used by default, but many doctypes are available.
Example::
- echo doctype(); // <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+ echo doctype(); // <!DOCTYPE html>
echo doctype('html4-trans'); // <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">