From 698066659774331dadd9cb0c1dab0aba795588b0 Mon Sep 17 00:00:00 2001
From: Christian Schneider
Date: Fri, 21 Feb 2014 13:54:54 +0100
Subject: Added support for htmltype 'html5' to it_html
---
it_html.class | 11 ++++++-----
tests/it_html.t | 8 ++++++++
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/it_html.class b/it_html.class
index 4b9dcf5..fbab0db 100644
--- a/it_html.class
+++ b/it_html.class
@@ -69,7 +69,7 @@ function it_html($p = array())
'charset' => ini_get('default_charset') ?: 'iso-8859-1',
'doctype' => null, # Custom doctype (will usually be calculated from htmltype)
'head' => '', # Code to put into head() section
- 'htmltype' => 'xhtml', # 'html' (=old-style), 'xhtml' or 'xhtml-mobile'
+ 'htmltype' => 'html5', # 'html5', 'html' (=old-style), 'xhtml' or 'xhtml-mobile'
'lang' => 'de', # Language code to use in tag
'ie_png_fix' => false, # To enable, supply URL of a transparent gif (like /images/0.gif)
'moretags' => '', # Comma-separated list of tag-functions to generate additionally to 'tags'
@@ -90,6 +90,7 @@ function it_html($p = array())
# We know these doctypes. If you need something else, supply 'doctype' in p
$this->doctypes = array(
+ 'html5' => '',
'html' => '',
'xhtml' => '',
'xhtml-mobile' => ''
@@ -181,7 +182,7 @@ function head($args = array())
$p += $this->p;
$this->p = ($p += array('content-type' => "text/html; charset={$p['charset']}"));
- $header = $p['show_content_type'] ? meta(array('http-equiv' => "Content-Type", 'content' => $p['content-type'])) : "";
+ $header = $p['show_content_type'] ? meta($p['htmltype'] == "html5" ? array('charset' => $p['charset']) : array('http-equiv' => "Content-Type", 'content' => $p['content-type'])) : "";
# Enable latest IE mode
if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
@@ -305,13 +306,13 @@ function _tag($name, $args)
$result .= " $key=\"$value\"";
}
else # true: tag without value
- $result .= ($this->p['htmltype'] == 'html') ? " $key" : " $key=\"$key\"";
+ $result .= ($this->p['htmltype'][0] != 'x') ? " $key" : " $key=\"$key\"";
}
# Apply a kind of magic... this needs further investigation
if (isset($data) || isset($this->alwaysclose[$name]))
$result .= ">$data$name>$newline";
- elseif ($this->p['htmltype'] == 'html')
+ elseif ($this->p['htmltype'][0] != 'x')
$result .= ">$newline";
else
$result .= " />$newline";
@@ -556,7 +557,7 @@ static function U(/* ... */)
*/
function js($args)
{
- if (($this->p['htmltype'] != 'html') && $args[0] && ((array)$args[0] === array_values((array)$args[0])))
+ if (($this->p['htmltype'][0] == 'x') && $args[0] && ((array)$args[0] === array_values((array)$args[0])))
{
array_unshift($args, "";
diff --git a/tests/it_html.t b/tests/it_html.t
index b50b3c9..4c06d9d 100755
--- a/tests/it_html.t
+++ b/tests/it_html.t
@@ -88,6 +88,14 @@ is(
"use html entities in attributes but not in normal text",
);
+# Test different html types
+foreach (array('html5' => "
", 'html' => "
", 'xhtml' => "
", 'xhtml-mobile' => "
") as $type => $value)
+{
+ unset($GLOBALS['it_html']);
+ new it_html(array('htmltype' => $type));
+ is (trim(br('flag' => true)), $value, "Check empty tag and attribute for $type");
+}
+
# XML generation
unset($GLOBALS['it_html']);
new it_html(array('htmltype' => "xhtml", 'tags' => "xmltest"));
--
cgit v1.2.3