Skip to content
Snippets Groups Projects
Commit 3825ddd3 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

include_once support for javascript

The include syntax was changed and enhanced by a include_once statement.

Syntax:

/* DOKUWIKI:include somefile.js */
/* DOKUWIKI:include_once someotherfile.js */

Note: include_once uses the basename of the inlcuded file to determine if
      it was previously loaded. You need to use something unique for it to
      make sure it is correctly loaded.

Note: included files are not checked for updates by the cache logic. You
      need to touch the master file for updating the cache

Note: includes are *not* supported inside included files to avoid any
      circular references

darcs-hash:20070513222421-7ad00-d99d717ba8a428d0af2b3f7d593897e0467cb9c9.gz
parent 82938a26
No related branches found
No related tags found
No related merge requests found
......@@ -165,13 +165,24 @@ function js_out(){
/**
* Load the given file, handle include calls and print it
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function js_load($file){
if(!@file_exists($file)) return;
static $loaded = array();
$data = io_readFile($file);
while(preg_match('#/\*\s*!!include\s+([\w\./]+)\s*\*/#',$data,$match)){
$ifile = $match[1];
while(preg_match('#/\*\s*DOKUWIKI:include(_once)\s+([\w\./]+)\s*\*/#',$data,$match)){
$ifile = $match[2];
// is it a include_once?
if($match[1]){
$base = basename($ifile);
if($loaded[$base]) continue;
$loaded[$base] = true;
}
if($ifile{0} != '/') $ifile = dirname($file).'/'.$ifile;
if(@file_exists($ifile)){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment