public int getType() {
return type;
}
public void execute(Environment env) throws TemplateException, IOException {
Scope scope = null;
if (namespaceExp != null) {
try {
scope = (Scope) namespaceExp.getAsTemplateModel(env);
} catch (ClassCastException cce) {
throw new InvalidReferenceException(getStartLocation() + "\nInvalid reference to namespace: " + namespaceExp, env);
}
}
else {
if (type == AssignmentInstruction.NAMESPACE) {
scope = env.getCurrentNamespace();
} else if (type == AssignmentInstruction.LOCAL) {
scope = env.getCurrentMacroContext();
} else if (type == AssignmentInstruction.GLOBAL) {
scope = env.getGlobalNamespace();
}
}
CaptureOutput filter = new CaptureOutput();
if (nestedBlock != null) {
env.render(nestedBlock, filter, null);
}
String text = filter.capturedText;
if (scope != null) {
scope.put(varName, new SimpleScalar(text));
} else {
env.unqualifiedSet(varName, new SimpleScalar(text));
}
}