W dniu 30.09.2010 10:43, Kornel Lesiński pisze:
On 29-09-2010 at 21:28:52 Piotr Kroczyński <piotr.kroczyn...@gmail.com> wrote:

They say that values with space or special chars must be quotes around. They don't say that quotes should be ommited everywhere else. Just mine interpretation :)

Can you send me test case where PHPTAL omits quotes when it shouldn't?


//////////////////////////////////////////// index.php ////////////////////////////////////////////////
<?php
require_once 'PHPTAL-1.2.1/PHPTAL.php';
$outputMode = PHPTAL::HTML5;
// create a new template object
$tpl = new PHPTAL();
$tpl->setPhpCodeDestination('/tmp/');
$tpl->setOutputMode($outputMode);
$tpl->setTemplateRepository(dirname(__FILE__));

$tpl->setTemplate('test.html');
echo $tpl->execute();
unset($tpl);
?>
//////////////////////////////////////// end of index.php /////////////////////////////////////////////


/////////////////////////////////////////// layout.html ////////////////////////////////////////////////////
<!DOCTYPE html>
<html metal:define-macro="layout">
<head>
<title>Phptal test</title>
</head>
<body id="myId">
<a href="http://google.pl/"; title="Google search ">Google</a>

<h1 metal:define-slot="content"></h1>
</body>
</html>
/////////////////////////////////////// end of layout.html //////////////////////////////////////////////


//////////////////////////////////////////// test.html ////////////////////////////////////////////////////////
<tal:block metal:use-macro="layout.html/layout">
<tal:block metal:fill-slot="content">
<a href="http://bing.com/"; title="Bing!Search."><span class="test-class" id="testId">Test</span></a>
</tal:block>
</tal:block>
/////////////////////////////////////////// end of test.html //////////////////////////////////////////////

/////////////////////////////////////// OUTPUT /////////////////////////////////////////////////////////////
<!DOCTYPE html>
<html>
<head>
<title>Phptal test</title>
</head>
<body id=myId>
<a href="http://google.pl/"; title="Google search ">Google</a>


<a href="http://bing.com/"; title=Bing!Search.><span class=test id=testId>Test</span></a>

</body>
</html>
////////////////////////////////// end of OUTPUT /////////////////////////////////////////////////////

Quotes around attributes, wich dont have special chars, were stripped (class, id etc), even when I wrapped them in quotes. Other values were left as they were. I think that if someone wrapped values in quotes they should stay that way if syntax is correct. Html looks better and much easier to read with wrapped values :)

Second thing, when i change template like that:

//////////////////////////////////////////// test.html ////////////////////////////////////////////////////////
<tal:block metal:use-macro="layout.html/layout">
<tal:block metal:fill-slot="content">
<a href="http://bing.com/"; title="Bing!Search."><span class="test-class" id=testId>Test</span></a>
</tal:block>
</tal:block>
/////////////////////////////////////////// end of test.html //////////////////////////////////////////////

 I get an exception:

/////////////////////////////////////////////////////////////
Fatal error: Uncaught From /var/www/phptal_test/test.html around line 3
exception 'PHPTAL_ParserException' with message 'Value of attribute id in < span > is not in quotes (found character 't' instead of quote)' in /var/www/phptal_test/test.html:3
Stack trace:
#0 /var/www/phptal_test/PHPTAL-1.2.1/PHPTAL/Dom/SaxXmlParser.php(316): PHPTAL_Dom_SaxXmlParser->raiseError('Value of attrib...') #1 /var/www/phptal_test/PHPTAL-1.2.1/PHPTAL.php(1113): PHPTAL_Dom_SaxXmlParser->parseString(Object(PHPTAL_Dom_DocumentBuilder), '<tal:block meta...', '/var/www/phptal...')
#2 /var/www/phptal_test/PHPTAL-1.2.1/PHPTAL.php(832): PHPTAL->parse()
#3 /var/www/phptal_test/PHPTAL-1.2.1/PHPTAL.php(651): PHPTAL->prepare()
#4 /var/www/phptal_test/index.php(16): PHPTAL->execute()
#5 {main}
  thrown in /var/www/phptal_test/test.html on line 3

////////////////////////////////////////////////////////////

So when using HTML5 mode in PHPTAL I need to wrap all values in quotes but in output I get them without quotes. Isn't it additional work for parser to remove quotes even when they are permitted in HTML5?


_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to