1 52 53 package freemarker.core; 54 55 import java.io.IOException ; 56 57 import freemarker.template.TemplateException; 58 59 62 final class DollarVariable extends TemplateElement { 63 64 private final Expression expression; 65 private final Expression escapedExpression; 66 67 DollarVariable(Expression expression, Expression escapedExpression) { 68 this.expression = expression; 69 this.escapedExpression = escapedExpression; 70 } 71 72 75 void accept(Environment env) throws TemplateException, IOException { 76 env.getOut().write(escapedExpression.getStringValue(env)); 77 } 78 79 public String getCanonicalForm() { 80 return "${" + expression.getCanonicalForm() + "}"; 81 } 82 83 public String getDescription() { 84 return this.getSource() + 85 (expression == escapedExpression 86 ? "" 87 : " escaped ${" + escapedExpression.getCanonicalForm() + "}"); 88 } 89 90 boolean heedsOpeningWhitespace() { 91 return true; 92 } 93 94 boolean heedsTrailingWhitespace() { 95 return true; 96 } 97 } 98 | Popular Tags |