1 52 53 package freemarker.core; 54 55 import java.io.IOException ; 56 import freemarker.template.*; 57 58 63 class EscapeBlock extends TemplateElement { 64 65 private final String variable; 66 private final Expression expr; 67 private Expression escapedExpr; 68 69 70 EscapeBlock(String variable, Expression expr, Expression escapedExpr) { 71 this.variable = variable; 72 this.expr = expr; 73 this.escapedExpr = escapedExpr; 74 } 75 76 void setContent(TemplateElement nestedBlock) { 77 this.nestedBlock = nestedBlock; 78 this.escapedExpr = null; 80 } 81 82 void accept(Environment env) throws TemplateException, IOException { 83 if (nestedBlock != null) { 84 env.visit(nestedBlock); 85 } 86 } 87 88 Expression doEscape(Expression subst) { 89 return escapedExpr.deepClone(variable, subst); 90 } 91 92 public String getDescription() { 93 return "escape " + variable + " as " + expr.toString(); 94 } 95 96 public String getCanonicalForm() { 97 return "<#escape " 98 + variable 99 + " as " 100 + expr.getCanonicalForm() 101 + ">" 102 + nestedBlock.getCanonicalForm() 103 + "</#escape>"; 104 } 105 } 106 | Popular Tags |