[dokuwiki] Re: JavaScript include conditionals

  • From: Chris Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Fri, 19 Jan 2007 13:56:37 +0000

Hi,

I'm not so keen on this "extra syntax". I think the helper plugin idea works better. If helper plugins are in place for common php code, why not use them for common javascript and css too. That to me makes more sense than introducing a new syntax.

Martin, you can "sort of" do includes with javascript although its not native. For a client side including example take a look at the dojo toolkit. For server side, tell your web server to process the .js files through the php processor and use <?php include('another.js')?>.

Cheers,

Chris

Martin Tschofen wrote:
One more thing that came to mind after realizing that templates always load
before plugins. It would need to apply to both.

I like includes better (don't I wish js would allow this). It would make it
much easier to work and maintain them.
What about adding a script.ini for templates and plugins to specify the
script files instead?...martin

On 1/19/07, Andreas Gohr <andi@xxxxxxxxxxxxxx> wrote:


> So I'm looking for a way to conditionally include this code.
>
> Two solutions came to mind.
> 1. Allow a specially formatted comment inside a script file that tags
> part of the script file as conditional:
> /*loadOnlyOnce:Name-of-block*/
>    conditional js code here
> /*loadOnlyOnce:Name-of-block*/
>
> in js.php during the clean out process capture each of these
> conditionals and when detected in another file ignore them.

I like this idea. Maybe we could even add an include mechanism, to
solve the problem many people had with only one script being allowed.
So instead of catting all my script files into one script.js I could
also use

/*include: script1.js*/
/*include: script2.js*/
/*include: script3.js*/

What do others think? The same could probably added to the CSS files as
well.

Andi

--
http://www.splitbrain.org
--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist



--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: