[TYPO3-dev] awesome javascript coding style

Ernesto Baschny [cron IT] ernst at cron-it.de
Thu Jun 16 11:02:04 CEST 2011


Dmitry Dulepov schrieb am 16.06.2011 09:40:
> 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.

It's not about XHTML, but about HTML5, where this "data-*" attributes
are valid [1].

Cheers,
Ernesto

[1]
http://dev.w3.org/html5/spec/elements.html#embedding-custom-non-visible-data




More information about the TYPO3-dev mailing list