[PHPTAL] PHPTAL writes DOCTYPE twice

2009-09-02 Thread Murat Çorlu

Hi all!

Firstly, thank you much to developers of PHPTal. It's great!

We have a problem. We have a master page and a plugin simulation that 
renders some another templates to called from. For example;


!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

html
head

/head
body
   div 
tal:replace=plugin/get_promoters/page_id/10/orientation/1/loads /

/body
/html

plugin is an object that has a getter magic function. It handles that 
parameters and execute-return another template like this:


tal:block tal:condition=php: orientation==2
   ul class=thumbView verticalPromoters
  liteste/li
   /ul
/tal:block

When we ran this, PHPTAL adds a DOCTYPE tag more to infront of second 
template. I didn't understand the problem. Can you give a suggestion?


Sincerely,
Murat Çorlu

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


[PHPTAL] Re: PHPTAL writes DOCTYPE twice

2009-09-02 Thread Szymek Przybył

Hi Murat!

Just remove DOCTYPE info from second template, it should be only in main 
template.



Cheers!
Szymek

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


Re: [PHPTAL] PHPTAL writes DOCTYPE twice

2009-09-02 Thread Kornel Lesiński

On 02-09-2009 at 10:39:11 Murat Çorlu muratco...@gmail.com wrote:

We have a problem. We have a master page and a plugin simulation that  
renders some another templates to called from. For example;


!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN  
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

html
head

/head
body
div  
tal:replace=plugin/get_promoters/page_id/10/orientation/1/loads /

/body
/html

plugin is an object that has a getter magic function. It handles that  
parameters and execute-return another template like this:


tal:block tal:condition=php: orientation==2
ul class=thumbView verticalPromoters
   liteste/li
/ul
/tal:block

When we ran this, PHPTAL adds a DOCTYPE tag more to infront of second  
template. I didn't understand the problem. Can you give a suggestion?


DOCTYPE and XML declaration are stored in PHPTAL's execution context (like  
a global variable that's prepended to all output) to allow subpages  
without DOCTYPE to call external macro that defines page layout and adds  
DOCTYPE, and you've caught PHPTAL red-handed by calling execute() on  
PHPTAL instance that has already seen a DOCTYPE.



I've added workaround for it in SVN. Try it out:
svn co https://svn.motion-twin.com/phptal/trunk phptal


Consider using more TAL-friendly macros, something like:

div metal:use-macro=plugins.xhtml/promoters tal:define=page_id '10';  
orientation '1'/



--
regards, Kornel

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


[PHPTAL] javascript code messed up

2009-09-02 Thread GRolf
I'm using a tal:block fill-slot=script to fill my macro template with
javascript code. However, all  are converted to $lt;, which (seems
to) cause an error in a for loop

for (i=0; i  myarray.lenght; i++) {
 ...
}

is converted to

for (i=0; i lt; myarray.lenght; i++) {
 ...
}

and I get an error at that line.



Any way to enforce phptal to put the content from the tal:block to
be passed as text ?

I tried specifying tal:block define-slot=structure script, but
that doesn't work...




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


Re: [PHPTAL] javascript code messed up

2009-09-02 Thread Kornel Lesiński

On 02-09-2009 at 14:12:39 Tjerk Meesters tjerk.meest...@gmail.com wrote:


Start your script with !-- and end with //--


You must *not* do that in XHTML, because in XHTML this may actually  
comment out the script. XHTML doesn't have HTML's magic treatment of  
script and comments in it.


--
regards, Kornel

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


Re: [PHPTAL] javascript code messed up

2009-09-02 Thread Kornel Lesiński

On 02-09-2009 at 14:04:15 GRolf ger...@pictureparking.com wrote:


I'm using a tal:block fill-slot=script to fill my macro template with
javascript code. However, all  are converted to $lt;, which (seems
to) cause an error in a for loop

for (i=0; i  myarray.lenght; i++) {
 ...
}

is converted to

for (i=0; i lt; myarray.lenght; i++) {
 ...
}

and I get an error at that line.


Apparently you're using text/html mode. Do you use HTML 5 output mode or  
XHTML?



XHTML requires  to be escaped as lt; (otherwise it would be ill-formed  
start of a tag).


HTML requires the opposite - it has hardcoded rule that script content  
is CDATA where entities aren't interpreted.




Any way to enforce phptal to put the content from the tal:block to
be passed as text ?


Strictly speaking it is passed as text, and text in markup has to be  
escaped.


Try wrapping script in fill-slot in /*![CDATA[*/ … /*]]*/. That is a  
workaround for XHTML served as HTML.


--
regards, Kornel

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


Re: [PHPTAL] PHPTAL writes DOCTYPE twice

2009-09-02 Thread Murat Çorlu
Macros are very well. It solved my problem. But I added something to 
solution: We needed plugin-like system to handle what will assign by 
template, not php. Plugin's html assigns will be sent when if only 
plugin is used on template. So, finally I use a system like this:


div metal:use-macro=plugins.xhtml/promoters 
tal:define=promoteAssings 
plugin/get_promoters/page_id/10/orientation/1/loads /


Here, plugin don't send any html. It sends only assign data to 
promoteAssigns variable. And we are using promoteAssigns variable in 
plugins.xhtml template.


This solved my problem. But maybe someone knows better way.

Thank you so much. And sorry my poor English..

Murat Çorlu

Kornel Lesiński yazmış:

On 02-09-2009 at 10:39:11 Murat Çorlu muratco...@gmail.com wrote:

We have a problem. We have a master page and a plugin simulation that 
renders some another templates to called from. For example;


!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;

html
head

/head
body
div 
tal:replace=plugin/get_promoters/page_id/10/orientation/1/loads /

/body
/html

plugin is an object that has a getter magic function. It handles that 
parameters and execute-return another template like this:


tal:block tal:condition=php: orientation==2
ul class=thumbView verticalPromoters
   liteste/li
/ul
/tal:block

When we ran this, PHPTAL adds a DOCTYPE tag more to infront of second 
template. I didn't understand the problem. Can you give a suggestion?


DOCTYPE and XML declaration are stored in PHPTAL's execution context 
(like a global variable that's prepended to all output) to allow 
subpages without DOCTYPE to call external macro that defines page 
layout and adds DOCTYPE, and you've caught PHPTAL red-handed by 
calling execute() on PHPTAL instance that has already seen a DOCTYPE.



I've added workaround for it in SVN. Try it out:
svn co https://svn.motion-twin.com/phptal/trunk phptal


Consider using more TAL-friendly macros, something like:

div metal:use-macro=plugins.xhtml/promoters tal:define=page_id 
'10'; orientation '1'/






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


Re[2]: [PHPTAL] javascript code messed up

2009-09-02 Thread GRolf

sorry, I overlooked your answer here.

I was using PHPTal in default output mode, I was not specifying
anything. I'm now specifying
$phpTal-setOutputMode(PHPTAL::XHTML);

My templates have doctype xhtml 1.0


Adding the /*![CDATA[*/ … /*]]*/ works fine (adding !-- -- too, at
least in FF)


thx!



 On 02-09-2009 at 14:04:15 GRolf ger...@pictureparking.com wrote:

 I'm using a tal:block fill-slot=script to fill my macro template with
 javascript code. However, all  are converted to $lt;, which (seems
 to) cause an error in a for loop

 for (i=0; i  myarray.lenght; i++) {
  ...
 }

 is converted to

 for (i=0; i lt; myarray.lenght; i++) {
  ...
 }

 and I get an error at that line.

 Apparently you're using text/html mode. Do you use HTML 5 output mode or
 XHTML?


 XHTML requires  to be escaped as lt; (otherwise it would be ill-formed
 start of a tag).

 HTML requires the opposite - it has hardcoded rule that script content
 is CDATA where entities aren't interpreted.


 Any way to enforce phptal to put the content from the tal:block to
 be passed as text ?

 Strictly speaking it is passed as text, and text in markup has to be  
 escaped.

 Try wrapping script in fill-slot in /*![CDATA[*/ … /*]]*/. That is a
 workaround for XHTML served as HTML.



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


Re: [PHPTAL] PHPTAL writes DOCTYPE twice

2009-09-02 Thread Kornel Lesiński

On 02-09-2009 at 15:45:11 Murat Çorlu muratco...@gmail.com wrote:

Macros are very well. It solved my problem. But I added something to  
solution: We needed plugin-like system to handle what will assign by  
template, not php. Plugin's html assigns will be sent when if only  
plugin is used on template. So, finally I use a system like this:


I'm not sure if I understand what you mean by what will assign.

If you want to use different TAL code for different plugins, you could use  
dynamic macro names:


div metal:use-macro=${plugin/which_macro_do_you_want} /


And if you need to handle cases when there's no plugin, then simply use  
tal:condition=exists:plugin or similar.


--
regards, Kornel

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


Re: [PHPTAL] javascript code messed up

2009-09-02 Thread Yannick Dirou

GRolf a écrit :

what solution would you propose then ?
  

IMHO javascript has nothing to do in (X)HTML,

use external file!

ie :
script type=text/javascript src=javascript.js/script

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