X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=JsTemplate.php;h=f1387913c57aa7251c3a593c07d4f5afd314b684;hb=692861c958898f425cc365906c092559d7cfc60c;hp=9bb8f4c8b741f545bc1cc08cdaff557fbbb4d478;hpb=7db9770de66e8541980299370edf86ea1f818066;p=Pman.Core diff --git a/JsTemplate.php b/JsTemplate.php index 9bb8f4c8..f1387913 100644 --- a/JsTemplate.php +++ b/JsTemplate.php @@ -40,10 +40,12 @@ class Pman_Core_JsTemplate extends Pman { } - function get() + function get($v, $opts=array()) { + + $this->sessionState(0); // get the modules. - //header('Content-type: text/javascript'); + header('Content-type: text/javascript'); $ff = HTML_FlexyFramework::get(); @@ -53,28 +55,32 @@ class Pman_Core_JsTemplate extends Pman { //print_r($mods); //$ar = explode(PATH_SEPARATOR, $ff->HTML_Template_Flexy['templateDir']); + array_push($mods, $pr); - $prefix = $pr == 'Pman' ? 'Pman.' : ''; - - foreach($mods as $mod) { - $dir = $this->rootDir .'/'.$pr . '/'. $mod . '/jtemplates'; + foreach($mods as $mod ) + { + $prefix = $mod == $pr ? "" : "{$pr}."; + //var_dump($prefix); + $pdir = $mod == $pr ? '' : ($pr .'/') ; + + $dir = $this->rootDir .'/'.$pdir . $mod . '/jtemplates'; if (!file_exists($dir)) { echo '// missing directory '. htmlspecialchars($dir) ."\n"; continue; } // got a directory.. - $mn = basename(dirname($mod)); + $ar = glob("$dir/*.html") ; if (empty($ar)) { echo '// no template is directory '. htmlspecialchars($dir) ."\n"; continue; } - echo "{$prefix}{$mn} = {$prefix}{$mn} || {};\n"; - echo "{$prefix}{$mn}.template = {$prefix}{$mn}.template || {};\n\n"; + echo "{$prefix}{$mod} = {$prefix}{$mod} || {};\n"; + echo "{$prefix}{$mod}.template = {$prefix}{$mod}.template || {};\n\n"; foreach(glob("$dir/*.html") as $fn) { - $name = "{$prefix}{$mn}.template." . preg_replace('/\.html$/i', '', basename($fn)); + $name = "{$prefix}{$mod}.template." . preg_replace('/\.html$/i', '', basename($fn)); echo $this->compile($fn, $name) . "\n"; @@ -107,7 +113,7 @@ class Pman_Core_JsTemplate extends Pman { $out= array(); - $head = "$name = function(t)\n{\n var ret = [];\n\n"; + $head = "$name = function(t)\n{\n var ret = '';\n\n"; $funcs = array(); // do not allow nested functions..?