X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=JsTemplate.php;h=f1387913c57aa7251c3a593c07d4f5afd314b684;hb=0b4f996ab1addf59265a29752045c08b2177260a;hp=0e8d3bde9d806028d7eb689912ab0601f998c5f2;hpb=f1ab54697176b14183a81d3ae2ccfb51d614f0f6;p=Pman.Core
diff --git a/JsTemplate.php b/JsTemplate.php
index 0e8d3bde..f1387913 100644
--- a/JsTemplate.php
+++ b/JsTemplate.php
@@ -40,37 +40,47 @@ class Pman_Core_JsTemplate extends Pman {
}
- function get()
+ function get($v, $opts=array())
{
+
+ $this->sessionState(0);
// get the modules.
header('Content-type: text/javascript');
$ff = HTML_FlexyFramework::get();
$pr = $ff->project;
- $ar = explode(PATH_SEPARATOR, $ff->HTML_Template_Flexy['templateDir']);
- $prefix = $pr == 'Pman' ? 'Pman.' : '';
+ $mods = $this->modulesList();
+ //print_r($mods);
+
+ //$ar = explode(PATH_SEPARATOR, $ff->HTML_Template_Flexy['templateDir']);
+ array_push($mods, $pr);
- foreach($ar as $mod) {
- $dir = dirname($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";
@@ -103,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..?
@@ -120,7 +130,7 @@ class Pman_Core_JsTemplate extends Pman {
continue;
case ($inscript && ($item != '{end:}')):
- $ret[] = $item;
+ $ret[count($ret)-1] .= $item;
continue;
case ($inscript && ($item == '{end:}')):
@@ -138,6 +148,7 @@ class Pman_Core_JsTemplate extends Pman {
case ($item == '{script:}'):
$inscript = true;
+ $ret[] = '';
continue;
case ($item[1] == '!'):
@@ -150,6 +161,13 @@ class Pman_Core_JsTemplate extends Pman {
$indent++;
continue;
+ case (substr($item,1,5) == 'else:'):
+ $indent--;
+ $in = str_repeat(" ", $indent);
+ $ret[] = $in . "} else { ";
+ $indent++;
+ continue;
+
case (substr($item,1,4) == 'end:'):
$indent--;
$in = str_repeat(" ", $indent);
@@ -181,7 +199,7 @@ class Pman_Core_JsTemplate extends Pman {
continue;
}
if (substr($item,-3,2) == ':b') {
- $ret[] = $in . "ret += Roo.util.Format.htmlEncode(". substr($item,1,-1).').split("\n").join("
\n");';
+ $ret[] = $in . "ret += Roo.util.Format.htmlEncode(". substr($item,1,-3).').split("\n").join("
\n");';
continue;
}
$ret[] = $in . "ret += Roo.util.Format.htmlEncode(". substr($item,1,-1).');';
@@ -192,7 +210,7 @@ class Pman_Core_JsTemplate extends Pman {
}
$in = str_repeat(" ", $indent);
- $ret[] = $in . "return ret.join('');\n}\n";
+ $ret[] = $in . "return ret;\n}\n";
return $head . implode("\n",$funcs) . "\n\n" .implode("\n",$out) ;
//echo '
' . htmlspecialchars(implode("\n",$ret));