Forums / Developer / A template for generating .js file

A template for generating .js file

Author Message

Kevin Gaudin

Friday 05 September 2008 2:55:22 am

Hi,

What would be the best technique for creating a template to generate a .js file which has to be included in every page of my site ?

Thanks for your help !

Twitter: @kevingaudin

Pierre Tissot

Monday 08 September 2008 8:24:37 am

Hi,

I would create the javascript code that as to be dynamic on the template itself (inside a <script> tag)

PiR

André R.

Tuesday 09 September 2008 12:43:23 am

Or if your not afraid of writing php (doc, settings, code):
http://svn.projects.ez.no/ezcore/trunk/ezcore/doc/ezscript.txt
http://svn.projects.ez.no/ezcore/trunk/ezcore/settings/ezcore.ini
http://svn.projects.ez.no/ezcore/trunk/ezcore/classes/ezcoreservercallfunctions.php

However this is only useful if you need to generate a lot of js dynamically, for instance like OE 5.x does with translations:

http://svn.ez.no/svn/extensions/eztinymce/trunk/ezoe/classes/ezoepackerfunctions.php

So if you have mostly static js, with a couple of dynamic values from template, I would rather split out the static part into a external js file (unless it's small of course) and put the dynamic part in script tags in your pagelayout.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom