|
@@ -78,7 +78,7 @@ class Parser {
|
|
function parseElement( xml:Xml ){
|
|
function parseElement( xml:Xml ){
|
|
var mtSet = extractAttribute(xml, MT_SET);
|
|
var mtSet = extractAttribute(xml, MT_SET);
|
|
if (mtSet != null){
|
|
if (mtSet != null){
|
|
- var incExp = ~/^([a-zA-Z_][a-zA-Z0-9_]*?)\s*?([\+\-\/*%])=\s*?(.*?)$/;
|
|
|
|
|
|
+ var incExp = ~/^([a-zA-Z_][a-zA-Z0-9_]*?)\s*?([\+\-\/*%])=\s*?(.*?)$/; // */
|
|
if (incExp.match(mtSet)){
|
|
if (incExp.match(mtSet)){
|
|
var dest = StringTools.trim(incExp.matched(1));
|
|
var dest = StringTools.trim(incExp.matched(1));
|
|
var op = incExp.matched(2);
|
|
var op = incExp.matched(2);
|
|
@@ -100,7 +100,7 @@ class Parser {
|
|
/*
|
|
/*
|
|
if (!mtwin.templo.Template.compiledFiles.exists(mtUse)){
|
|
if (!mtwin.templo.Template.compiledFiles.exists(mtUse)){
|
|
mtwin.templo.Template.compiledFiles.set(mtUse, true);
|
|
mtwin.templo.Template.compiledFiles.set(mtUse, true);
|
|
- var f = mtwin.templo.Template.fromFile(mtUse);
|
|
|
|
|
|
+ var f = mtwin.templo.Template.fromFile(mtUse);
|
|
}
|
|
}
|
|
*/
|
|
*/
|
|
out.add("tmp = "+out.getVar("__content__")+";\n");
|
|
out.add("tmp = "+out.getVar("__content__")+";\n");
|
|
@@ -117,7 +117,7 @@ class Parser {
|
|
out.setVar("__content__", "tmp");
|
|
out.setVar("__content__", "tmp");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
var mtFill = extractAttribute(xml, MT_FILL);
|
|
var mtFill = extractAttribute(xml, MT_FILL);
|
|
if (mtFill != null){
|
|
if (mtFill != null){
|
|
out.add("__out = new_output_buffer(__out);\n");
|
|
out.add("__out = new_output_buffer(__out);\n");
|
|
@@ -126,7 +126,7 @@ class Parser {
|
|
out.add("__out = __out.parent;\n");
|
|
out.add("__out = __out.parent;\n");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
var mtIf = extractAttribute(xml, MT_IF);
|
|
var mtIf = extractAttribute(xml, MT_IF);
|
|
if (mtIf != null){
|
|
if (mtIf != null){
|
|
out.add("if (is_true("+parseExpression(mtIf)+")){\n");
|
|
out.add("if (is_true("+parseExpression(mtIf)+")){\n");
|
|
@@ -134,7 +134,7 @@ class Parser {
|
|
out.add("}\n");
|
|
out.add("}\n");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
var mtElseIf = extractAttribute(xml, MT_ELSEIF);
|
|
var mtElseIf = extractAttribute(xml, MT_ELSEIF);
|
|
if (mtElseIf != null){
|
|
if (mtElseIf != null){
|
|
out.add("else if (is_true("+parseExpression(mtElseIf)+")){\n");
|
|
out.add("else if (is_true("+parseExpression(mtElseIf)+")){\n");
|
|
@@ -142,7 +142,7 @@ class Parser {
|
|
out.add("}\n");
|
|
out.add("}\n");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
var mtElse = extractAttribute(xml, MT_ELSE);
|
|
var mtElse = extractAttribute(xml, MT_ELSE);
|
|
if (mtElse != null){
|
|
if (mtElse != null){
|
|
out.add("else {\n");
|
|
out.add("else {\n");
|
|
@@ -153,7 +153,7 @@ class Parser {
|
|
|
|
|
|
var mtForeach = extractAttribute(xml, MT_FOREACH);
|
|
var mtForeach = extractAttribute(xml, MT_FOREACH);
|
|
if (mtForeach != null){
|
|
if (mtForeach != null){
|
|
- var o = extractExpressionTarget(mtForeach);
|
|
|
|
|
|
+ var o = extractExpressionTarget(mtForeach);
|
|
if (o.target == null)
|
|
if (o.target == null)
|
|
throw "repeat/foreach requires two parameters (expression was '"+mtForeach+"')";
|
|
throw "repeat/foreach requires two parameters (expression was '"+mtForeach+"')";
|
|
out.add("var loop = "+parseExpression(o.exp)+";\n");
|
|
out.add("var loop = "+parseExpression(o.exp)+";\n");
|
|
@@ -176,7 +176,7 @@ class Parser {
|
|
if (mtOmitTag == null && xml.nodeName == MT){
|
|
if (mtOmitTag == null && xml.nodeName == MT){
|
|
mtOmitTag = "true";
|
|
mtOmitTag = "true";
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
var mtAttributes = extractAttribute(xml, MT_ATTRIBUTES);
|
|
var mtAttributes = extractAttribute(xml, MT_ATTRIBUTES);
|
|
var mtContent = extractAttribute(xml, MT_CONTENT);
|
|
var mtContent = extractAttribute(xml, MT_CONTENT);
|
|
|
|
|
|
@@ -189,7 +189,7 @@ class Parser {
|
|
if (xhtmlMode && !hasContent && !xhtmlEmpty){
|
|
if (xhtmlMode && !hasContent && !xhtmlEmpty){
|
|
hasContent = true;
|
|
hasContent = true;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (mtOmitTag == null){
|
|
if (mtOmitTag == null){
|
|
out.writeHtml("<"+xml.nodeName);
|
|
out.writeHtml("<"+xml.nodeName);
|
|
if (mtAttributes != null){
|
|
if (mtAttributes != null){
|
|
@@ -198,7 +198,7 @@ class Parser {
|
|
else {
|
|
else {
|
|
echoAttributes(xml);
|
|
echoAttributes(xml);
|
|
}
|
|
}
|
|
- if (hasContent){
|
|
|
|
|
|
+ if (hasContent){
|
|
out.writeHtml(">");
|
|
out.writeHtml(">");
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -206,7 +206,7 @@ class Parser {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (mtContent != null){
|
|
if (mtContent != null){
|
|
echoExpression(mtContent);
|
|
echoExpression(mtContent);
|
|
}
|
|
}
|
|
@@ -214,7 +214,7 @@ class Parser {
|
|
for (child in xml)
|
|
for (child in xml)
|
|
parseNode(child);
|
|
parseNode(child);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (mtOmitTag == null && hasContent){
|
|
if (mtOmitTag == null && hasContent){
|
|
out.writeHtml("</" + xml.nodeName + ">");
|
|
out.writeHtml("</" + xml.nodeName + ">");
|
|
}
|
|
}
|
|
@@ -367,11 +367,11 @@ class Parser {
|
|
var i = 0;
|
|
var i = 0;
|
|
while (i < len){
|
|
while (i < len){
|
|
var c = str.charAt(i);
|
|
var c = str.charAt(i);
|
|
- if (c == "("){
|
|
|
|
- cto++;
|
|
|
|
|
|
+ if (c == "("){
|
|
|
|
+ cto++;
|
|
}
|
|
}
|
|
- else if (c == ")"){
|
|
|
|
- cto--;
|
|
|
|
|
|
+ else if (c == ")"){
|
|
|
|
+ cto--;
|
|
}
|
|
}
|
|
|
|
|
|
if (c == "\\"){
|
|
if (c == "\\"){
|
|
@@ -411,8 +411,8 @@ class Parser {
|
|
if (c == "," && ctopen == 0){
|
|
if (c == "," && ctopen == 0){
|
|
n++;
|
|
n++;
|
|
}
|
|
}
|
|
- if (c == "["){
|
|
|
|
- ctopen++;
|
|
|
|
|
|
+ if (c == "["){
|
|
|
|
+ ctopen++;
|
|
}
|
|
}
|
|
else if (c == "]"){
|
|
else if (c == "]"){
|
|
if (ctopen == 0){
|
|
if (ctopen == 0){
|
|
@@ -433,8 +433,8 @@ class Parser {
|
|
var ctopen = 0;
|
|
var ctopen = 0;
|
|
for (i in (pos+1)...(len)){
|
|
for (i in (pos+1)...(len)){
|
|
var c = str.charAt(i);
|
|
var c = str.charAt(i);
|
|
- if (c == "("){
|
|
|
|
- ctopen++;
|
|
|
|
|
|
+ if (c == "("){
|
|
|
|
+ ctopen++;
|
|
}
|
|
}
|
|
else if (c == ")"){
|
|
else if (c == ")"){
|
|
if (ctopen == 0){
|
|
if (ctopen == 0){
|
|
@@ -475,7 +475,7 @@ class Parser {
|
|
return varName == "true" || varName == "false" || varName == "null" || varName == "if" || varName == "else";
|
|
return varName == "true" || varName == "false" || varName == "null" || varName == "if" || varName == "else";
|
|
}
|
|
}
|
|
|
|
|
|
- // Quick and 'dirty' expression transformer,
|
|
|
|
|
|
+ // Quick and 'dirty' expression transformer,
|
|
// This function transform a template expression into a neko compliant expression.
|
|
// This function transform a template expression into a neko compliant expression.
|
|
public static function parseExpression( exp:String ) : String {
|
|
public static function parseExpression( exp:String ) : String {
|
|
var r_num = ~/[0-9]+/;
|
|
var r_num = ~/[0-9]+/;
|
|
@@ -525,7 +525,7 @@ class Parser {
|
|
if (str.substr(i,5) == "&"){
|
|
if (str.substr(i,5) == "&"){
|
|
result.add("&"); i+=4; skip = true;
|
|
result.add("&"); i+=4; skip = true;
|
|
}
|
|
}
|
|
- if (str.substr(i,4) == "<"){
|
|
|
|
|
|
+ if (str.substr(i,4) == "<"){
|
|
result.add("<"); i+=3; skip = true;
|
|
result.add("<"); i+=3; skip = true;
|
|
}
|
|
}
|
|
else if (str.substr(i,4) == ">"){
|
|
else if (str.substr(i,4) == ">"){
|
|
@@ -565,10 +565,10 @@ class Parser {
|
|
}
|
|
}
|
|
|
|
|
|
case states.string:
|
|
case states.string:
|
|
- if (c == "\\" && n == "'"){
|
|
|
|
|
|
+ if (c == "\\" && n == "'"){
|
|
result.add("'");
|
|
result.add("'");
|
|
skip = true;
|
|
skip = true;
|
|
- ++i;
|
|
|
|
|
|
+ ++i;
|
|
}
|
|
}
|
|
else if (c == "\\" && n == "\""){
|
|
else if (c == "\\" && n == "\""){
|
|
skip = true;
|
|
skip = true;
|
|
@@ -578,7 +578,7 @@ class Parser {
|
|
result.add("\")");
|
|
result.add("\")");
|
|
skip = true;
|
|
skip = true;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
case states.dstring:
|
|
case states.dstring:
|
|
if (c == "\\" && n == "\""){
|
|
if (c == "\\" && n == "\""){
|
|
result.add("\\\"");
|
|
result.add("\\\"");
|
|
@@ -636,7 +636,7 @@ class Parser {
|
|
skip = true;
|
|
skip = true;
|
|
state = states.none;
|
|
state = states.none;
|
|
}
|
|
}
|
|
- else {
|
|
|
|
|
|
+ else {
|
|
result.add("__ctx.get(");
|
|
result.add("__ctx.get(");
|
|
result.add(Generator.hash(variable));
|
|
result.add(Generator.hash(variable));
|
|
result.add(")");
|
|
result.add(")");
|
|
@@ -648,7 +648,7 @@ class Parser {
|
|
if (!r_digit.match(c)){
|
|
if (!r_digit.match(c)){
|
|
state = states.none;
|
|
state = states.none;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
case states.member:
|
|
case states.member:
|
|
if (r_var.match(c)){
|
|
if (r_var.match(c)){
|
|
}
|
|
}
|