[TYPO3-dev] awesome javascript coding style

Dmitry Dulepov dmitry.dulepov at gmail.com
Thu Jun 16 09:40:14 CEST 2011


Hi!

Thomas Allmer wrote:
> I'm pretty impressed by behaviour and it will definitely change the way
> how I will write my JavaScript... maybe it will also help some of you... :)
>
> <http://www.clientcide.com/code-releases/clientcide-3-0-behavior-1-0-mootools-development-and-so-much-more/>

I prefer to have a valid XHTML and that would not be valid. I usually put a 
configuration block as inline js on the page. Something like this:

<?php

$config = array(
	'redirect_url' => $this->cObj->typolink(...),
	...
);

$content = '<script type="text/javascript">var namespace.module_config=' .
	json_encode($config) . '</script>';

?>

Easy, fast and valid.

-- 
Dmitry "itoldyou" Dulepov
TYPO3 core&security team member
E-mail: dmitry.dulepov at typo3.org
Web: http://dmitry-dulepov.com/





More information about the TYPO3-dev mailing list