Made the set tag work to local variables. Moved tests to their own directory.
This commit is contained in:
parent
ad48c530a0
commit
ae4ff5a3dc
2
Tag.cpp
2
Tag.cpp
@ -51,7 +51,7 @@ namespace jet {
|
|||||||
if(!finished) {
|
if(!finished) {
|
||||||
coreutils::ZString keywordName = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
|
coreutils::ZString keywordName = in.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
|
||||||
if(in.ifNext("=\"")) {
|
if(in.ifNext("=\"")) {
|
||||||
variables[keywordName] = KeywordValue(in.getTokenExclude("\""), global, variables);
|
variables[keywordName] = KeywordValue(in.getTokenExclude("\""), global, parent->variables);
|
||||||
}
|
}
|
||||||
if(!in.ifNext("\"")) {}
|
if(!in.ifNext("\"")) {}
|
||||||
}
|
}
|
||||||
|
41
__set.cpp
41
__set.cpp
@ -17,22 +17,33 @@ namespace jet {
|
|||||||
throw coreutils::Exception("set tag cannot have both expr and value.");
|
throw coreutils::Exception("set tag cannot have both expr and value.");
|
||||||
if(!variableDefined("expr") && !variableDefined("value") && !hasContainer)
|
if(!variableDefined("expr") && !variableDefined("value") && !hasContainer)
|
||||||
throw coreutils::Exception("set tag must have a value, expr or a container.");
|
throw coreutils::Exception("set tag must have a value, expr or a container.");
|
||||||
if(!variableDefined("scope") || (variables["scope"] == "global")) {
|
if(variableDefined("expr") && variableDefined("eval"))
|
||||||
if(variableDefined("expr")) {
|
throw coreutils::Exception("Cannot use eval with expr.");
|
||||||
if(variableDefined("eval"))
|
|
||||||
throw coreutils::Exception("Cannot use eval with expr.");
|
|
||||||
global.variables[variables["name"]] = Operand(variables["expr"]).string;
|
|
||||||
} else if(hasContainer) {
|
|
||||||
processContainer(container);
|
|
||||||
if(evaluate) {
|
|
||||||
global.variables[variables["name"]] = out;
|
|
||||||
} else {
|
|
||||||
global.variables[variables["name"]] = container;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
global.variables[variables["name"]] = variables["value"];
|
|
||||||
} else {
|
|
||||||
|
|
||||||
|
if(variableDefined("expr")) {
|
||||||
|
if(!variableDefined("scope") || (variables["scope"] == "global"))
|
||||||
|
global.variables[variables["name"]] = Operand(variables["expr"]).string;
|
||||||
|
else if(variables["scope"] == "local")
|
||||||
|
variables[variables["name"]] = Operand(variables["expr"]).string;
|
||||||
|
} else if(hasContainer) {
|
||||||
|
processContainer(container);
|
||||||
|
if(evaluate) {
|
||||||
|
if(!variableDefined("scope") || (variables["scope"] == "global"))
|
||||||
|
global.variables[variables["name"]] = out;
|
||||||
|
else if(variables["scope"] == "local")
|
||||||
|
variables[variables["name"]] = out;
|
||||||
|
} else {
|
||||||
|
if(!variableDefined("scope") || (variables["scope"] == "global"))
|
||||||
|
global.variables[variables["name"]] = container;
|
||||||
|
else if(variables["scope"] == "local")
|
||||||
|
variables[variables["name"]] = container;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(!variableDefined("scope") || (variables["scope"] == "global"))
|
||||||
|
global.variables[variables["name"]] = variables["value"];
|
||||||
|
else if(variables["scope"] == "local")
|
||||||
|
variables[variables["name"]] = variables["value"];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
tests/testscope.jet
Executable file
8
tests/testscope.jet
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!./jet-2.0
|
||||||
|
<jet cgi="true" name1="localname" filterblanklines="true" trimlines="true">
|
||||||
|
<set name="testvar" value="do you see this" scope="local" />
|
||||||
|
#[testvar]
|
||||||
|
<for name="ix" start="1" end="5" step="1">
|
||||||
|
-->#[ix]<--
|
||||||
|
</for>
|
||||||
|
</jet>
|
@ -1,4 +1,4 @@
|
|||||||
#!./jet-2.0
|
#!../jet-2.0
|
||||||
<jet filterblanklines="true" trimlines="true">
|
<jet filterblanklines="true" trimlines="true">
|
||||||
<set name="ix" value="1" />
|
<set name="ix" value="1" />
|
||||||
<set name="letterx" value="x" />
|
<set name="letterx" value="x" />
|
Loading…
x
Reference in New Issue
Block a user