Hi All,
I've discovered drupal just couple weeks ago and I like it :) "Pro Drupal Development" bought and read and I'm ready to play with it :)
PHPTAL looks really nice in Dreamweaver so I'd like to use it in my sites.
But there's a problem with JavaScript - on output the apostrophe char ' is replaced by '
It happens only with PHPTAL theme engine (zental theme was used) - doesn't matter if apostrophe was inserted via drupal_add_js(..., 'inline') or like in FCKeditor as $element['#suffix'].
Is it a feature of PHPTAL? Does it encodes everything? Is that a reason for decoding it - like in here?
<?php // $Id: phptal.engine,v 1.9 2007/02/20 21:32:28 olav Exp $
... 73: return html_entity_decode($phptal->execute());
Cheers, Alex
For those who still would like to use PHPTAL engine:
In PHPTAL compiled templates (more or less it's a similar approach to the way perl Template-Toolkit works) variables are printed via phptal_escape with ENT_QUOTES.
phptal_escape then calls htmlspecialchars, and because of ENT_QUOTES "both single and double quotes are translated".
Does anyone know what kind of advantage is to encode both single and double quotes?
Replacing ENT_QUOTES with ENT_COMPAT in PHPTAL/Php/State.php (line 112, PHPTAL version 1.1.9) fixes problem with inline JS.
Cheers, Alex
Alex J. G. Burzyński pisze:
Hi All,
I've discovered drupal just couple weeks ago and I like it :) "Pro Drupal Development" bought and read and I'm ready to play with it :)
PHPTAL looks really nice in Dreamweaver so I'd like to use it in my sites.
But there's a problem with JavaScript - on output the apostrophe char ' is replaced by '
It happens only with PHPTAL theme engine (zental theme was used) - doesn't matter if apostrophe was inserted via drupal_add_js(..., 'inline') or like in FCKeditor as $element['#suffix'].
Is it a feature of PHPTAL? Does it encodes everything? Is that a reason for decoding it - like in here?
<?php // $Id: phptal.engine,v 1.9 2007/02/20 21:32:28 olav Exp $
... 73: return html_entity_decode($phptal->execute());
Cheers, Alex
On Dec 10, 2007 8:57 AM, "Alex J. G. Burzyński" ajgb@ajgb.net wrote:
Hi All,
I've discovered drupal just couple weeks ago and I like it :) "Pro Drupal Development" bought and read and I'm ready to play with it :)
PHPTAL looks really nice in Dreamweaver so I'd like to use it in my sites.
But there's a problem with JavaScript - on output the apostrophe char ' is replaced by '
It happens only with PHPTAL theme engine (zental theme was used) - doesn't matter if apostrophe was inserted via drupal_add_js(..., 'inline') or like in FCKeditor as $element['#suffix'].
Is it a feature of PHPTAL? Does it encodes everything? Is that a reason for decoding it - like in here?
<?php // $Id: phptal.engine,v 1.9 2007/02/20 21:32:28 olav Exp $
... 73: return html_entity_decode($phptal->execute());
If you enclose your JS inside CDATA tags, PHPTAL skips parsing it.
Cheers.
Thanks James answer!
This way I've made it work:
<?php $template->idratherusephptemplate = " document.ready(function(){\n alert('It works!');\n });\n";
// .tal <script type="text/javascript"> //<![CDATA[ ${idratherusephptemplate} //]]> </script>
But please note that I've encounter that problem when I've added FCKeditor module - which does not use CDATA when adding <script> to $element['#suffix']. And with quick grep I've found that imce is also adding inline JS.
So there's a way to use inline JS with PHPTAL but I'm not sure if it would work with drupal.
Cheers, Alex
James McLean pisze:
On Dec 10, 2007 8:57 AM, "Alex J. G. Burzyński" ajgb@ajgb.net wrote:
Hi All,
I've discovered drupal just couple weeks ago and I like it :) "Pro Drupal Development" bought and read and I'm ready to play with it :)
PHPTAL looks really nice in Dreamweaver so I'd like to use it in my sites.
But there's a problem with JavaScript - on output the apostrophe char ' is replaced by '
It happens only with PHPTAL theme engine (zental theme was used) - doesn't matter if apostrophe was inserted via drupal_add_js(..., 'inline') or like in FCKeditor as $element['#suffix'].
Is it a feature of PHPTAL? Does it encodes everything? Is that a reason for decoding it - like in here?
<?php // $Id: phptal.engine,v 1.9 2007/02/20 21:32:28 olav Exp $
... 73: return html_entity_decode($phptal->execute());
If you enclose your JS inside CDATA tags, PHPTAL skips parsing it.
Cheers.
After some digging I've found that PHPTAL was doing right thing - but phptal engine (and templates) should be fixed.
I've included cvs diff against DRUPAL-5: http://drupal.org/node/200018
This is fix for phptal default engine - I've got another one for zental but phptal.engine needs to be patched.
Cheers, Alex
Alex J. G. Burzyński pisze:
Hi All,
I've discovered drupal just couple weeks ago and I like it :) "Pro Drupal Development" bought and read and I'm ready to play with it :)
PHPTAL looks really nice in Dreamweaver so I'd like to use it in my sites.
But there's a problem with JavaScript - on output the apostrophe char ' is replaced by '
It happens only with PHPTAL theme engine (zental theme was used) - doesn't matter if apostrophe was inserted via drupal_add_js(..., 'inline') or like in FCKeditor as $element['#suffix'].
Is it a feature of PHPTAL? Does it encodes everything? Is that a reason for decoding it - like in here?
<?php // $Id: phptal.engine,v 1.9 2007/02/20 21:32:28 olav Exp $
... 73: return html_entity_decode($phptal->execute());
Cheers, Alex