Re: [PHPTAL] Why PHPTAL stop rendering doctype after clone.
W dniu 30.09.2010 19:37, Kornel Lesiński pisze: On 30 Sep 2010, at 18:28, Piotr Kroczyński wrote: Ok thank you for reply. I have just one more question. In which revision is that diry quick fix that you wrote earlier to make PHPTAL write doctype after clone? I just added this to svn:externals in place of 1.2.1: r993 phptal -r 939 https://svn.motion-twin.com/phptal/trunk/classes/ to svn externals Wrong revision number. But problem is still there. Can you tell me where and what to add to fix this bug ? The fix is in PHPTAL_Context::setDocType(). Sets it in current context, rather than topmost context. I'm not sure if that is sufficient in all cases, but passes test case you've sent me (which I've added to tests in r991). Sorry, I had good revision number but made mistake typing it in email :). Error remain, but maby it is somehow Zend Framework fault. I'm using Zend_View_Helper_Action to make something like widgets on my webpage: /// This helper clones controller object (all properties are cloned also so view is cloned too), then execute method and returns generated content (using output buffering I suppose). I use PHPTAL to generate html in those actions. Maby somewhere there is problem. Templates that actions use are quite simple. There is no doctype, html, body etc. Just something like that: // . /// I'll try try understand and modify PHPTAL to get it working. Maby I'll suceed, then I'll write how I did it :). If not then I'll wait for you to do it :) Thank you for help :) Cheers. ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Why PHPTAL stop rendering doctype after clone.
On 30 Sep 2010, at 18:28, Piotr Kroczyński wrote: > Ok thank you for reply. I have just one more question. In which revision is > that diry quick fix that you wrote earlier to make PHPTAL write doctype after > clone? I just added this to svn:externals in place of 1.2.1: r993 > phptal -r 939 https://svn.motion-twin.com/phptal/trunk/classes/ to svn > externals Wrong revision number. > But problem is still there. Can you tell me where and what to add to fix this > bug ? The fix is in PHPTAL_Context::setDocType(). Sets it in current context, rather than topmost context. I'm not sure if that is sufficient in all cases, but passes test case you've sent me (which I've added to tests in r991). -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Why PHPTAL stop rendering doctype after clone.
Ok thank you for reply. I have just one more question. In which revision is that diry quick fix that you wrote earlier to make PHPTAL write doctype after clone? I just added this to svn:externals in place of 1.2.1: phptal -r 939 https://svn.motion-twin.com/phptal/trunk/classes/ to svn externals But problem is still there. Can you tell me where and what to add to fix this bug ? ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Why PHPTAL stop rendering doctype after clone.
> 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 has HTML5 *output* mode. Input is always XML (I haven't gotten around to writing HTML5 parser yet). PHPTAL doesn't output markup you write. It reads markup into abstract tree (DOM) and then from that syntax-less tree generates PHP code that generates new markup. Input is completely separated from output. This is similar to the way browsers process markup (e.g., code in innerHTML doesn't retain any syntactical details from your page source). In current implementation decision to generate quotes is taken at compile time, so there's absolutely no penalty at run time. It might even be microscopically faster, as template code ends up few bytes shorter :) -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Why PHPTAL stop rendering doctype after clone.
W dniu 30.09.2010 10:43, Kornel Lesiński pisze: On 29-09-2010 at 21:28:52 Piotr Kroczyński 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 setPhpCodeDestination('/tmp/'); $tpl->setOutputMode($outputMode); $tpl->setTemplateRepository(dirname(__FILE__)); $tpl->setTemplate('test.html'); echo $tpl->execute(); unset($tpl); ?> end of index.php / /// layout.html Phptal test http://google.pl/"; title="Google search ">Google /// end of layout.html // test.html http://bing.com/"; title="Bing!Search.">id="testId">Test /// end of test.html // /// OUTPUT / Phptal test http://google.pl/"; title="Google search ">Google http://bing.com/"; title=Bing!Search.>id=testId>Test // 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 http://bing.com/"; title="Bing!Search.">id=testId>Test /// 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), ' #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
Re: [PHPTAL] Why PHPTAL stop rendering doctype after clone.
On 29-09-2010 at 21:28:52 Piotr Kroczyński 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? -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Why PHPTAL stop rendering doctype after clone.
W dniu 29.09.2010 11:53, Kornel Lesiński pisze: Thanks for the test case — it was very helpful. Short story: it's a bug. Ok thanks for info. Until it's fixed, I'll use this dirty fix :). When I change output mode to HTML5, PHPTAL generates broken html (no quotes around attributes values, does not matter if after clone or before) and does not change/validate doctype in layout.html. Is this normal? Do you mean it's broken according to HTML5 specification, or broken because it doesn't look like XML? In HTML5 mode omitting of quotes is intentional and PHPTAL should omit them only in cases permitted in HTML5 text/html syntax. On http://dev.w3.org/html5/spec/Overview.html#introduction they wrote: Attributes are placed inside the start tag, and consist of a name and a value, separated by an "=" character. The attribute value can remain unquoted if it doesn't contain spaces or any of " ' ` = < or >. Otherwise, it has to be quoted using either single or double quotes. The value, along with the "=" character, can be omitted altogether if the value is the empty string. // Correct me if I'm wrong. 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 :) PHPTAL also is supposed to force DOCTYPE to be the only one allowed in HTML5 (so you could have well-formed XHTML/1 with named entities as input and HTML5 as output). If it doesn't do that, then I'd like to see a test case for it. Ok I must have see it wrong :) PHPTAL is forcing doctype when in HTML5. Thank you for help. Regards Piotr Kroczyński ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] Why PHPTAL stop rendering doctype after clone.
On 27 Sep 2010, at 22:22, Piotr Kroczyński wrote: > > After clone PHPTAL stripped doctype... Why ? Thanks for the test case — it was very helpful. Short story: it's a bug. Long story: PHPTAL stores template state in nested PHPTAL_Context objects (tal:define, tal:repeat, macro calls, etc. create nested contexts). Clone of PHPTAL creates nested context too, which keeps reference to previous context. This makes new PHPTAL object behave like macro running in the old one (in fact that's how macros are executed). So the problem is that cloned PHPTAL tries to set DOCTYPE in outermost context, which happens to be still in the previous PHPTAL object. I've added quick'n'dirty fix for it in SVN (by setting DOCTYPE in two places). Proper fix might need some refactoring to eliminate cloning of PHPTAL in macro calls :( > When I change output mode to HTML5, PHPTAL generates broken html (no quotes > around attributes values, does not matter if after clone or before) and does > not change/validate doctype in layout.html. Is this normal? Do you mean it's broken according to HTML5 specification, or broken because it doesn't look like XML? In HTML5 mode omitting of quotes is intentional and PHPTAL should omit them only in cases permitted in HTML5 text/html syntax. PHPTAL also is supposed to force DOCTYPE to be the only one allowed in HTML5 (so you could have well-formed XHTML/1 with named entities as input and HTML5 as output). If it doesn't do that, then I'd like to see a test case for it. -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal