Package com.google.clearsilver.jsilver.values

Examples of com.google.clearsilver.jsilver.values.Value


  @Override
  public void caseAVarCommand(AVarCommand node) {
    setLastPosition(node.getPosition());

    // Evaluate expression.
    Value value = expressionEvaluator.evaluate(node.getExpression());
    writeVariable(value);
  }
View Full Code Here


  @Override
  public void caseAUvarCommand(AUvarCommand node) {
    setLastPosition(node.getPosition());

    // Evaluate expression.
    Value value = expressionEvaluator.evaluate(node.getExpression());
    context.writeUnescaped(value.asString());
  }
View Full Code Here

    evaluateVariable(node.getExpression(), "[evar expression]");
  }

  private void evaluateVariable(PExpression expression, String stackTraceDescription) {
    // Evaluate expression.
    Value value = expressionEvaluator.evaluate(expression);

    // Now parse result, into new mini template.
    Template template =
        templateLoader.createTemp(stackTraceDescription, value.asString(), context
            .getAutoEscapeMode());

    // Intepret new template.
    try {
      template.render(context);
View Full Code Here

    setLastPosition(node.getPosition());
    String variableName = variableLocator.getVariableName(node.getVariable());

    try {
      Data variable = dataContext.findVariable(variableName, true);
      Value value = expressionEvaluator.evaluate(node.getExpression());
      variable.setValue(value.asString());
      // TODO: what about nested structures?
      // "set" was used to set a variable to a constant or escaped value like
      // <?cs set: x = "<b>X</b>" ?> or <?cs set: y = html_escape(x) ?>
      // Keep track of this so autoescaping code can take it into account.
      variable.setEscapeMode(value.getEscapeMode());
    } catch (UnsupportedOperationException e) {
      // An error occurred - probably due to trying to modify an UnmodifiableData
      throw new UnsupportedOperationException(createUnsupportedOperationMessage(node, context
          .getIncludedTemplateNames()), e);
    }
View Full Code Here

   * &lt;?cs if:blah &gt; ... &lt;?cs else &gt; ... &lt;?cs /if &gt; command.
   */
  @Override
  public void caseAIfCommand(AIfCommand node) {
    setLastPosition(node.getPosition());
    Value value = expressionEvaluator.evaluate(node.getExpression());
    if (value.asBoolean()) {
      node.getBlock().apply(this);
    } else {
      node.getOtherwise().apply(this);
    }
  }
View Full Code Here

   * &lt;?cs escape:'html' &gt; command. Changes default escaping function.
   */
  @Override
  public void caseAEscapeCommand(AEscapeCommand node) {
    setLastPosition(node.getPosition());
    Value value = expressionEvaluator.evaluate(node.getExpression());
    String escapeStrategy = value.asString();

    context.pushEscapingFunction(escapeStrategy);
    node.getCommand().apply(this);
    context.popEscapingFunction();
  }
View Full Code Here

   * and stores this context in the AAutoescapeCommand node.
   */
  @Override
  public void caseAAutoescapeCommand(AAutoescapeCommand node) {
    setLastPosition(node.getPosition());
    Value value = expressionEvaluator.evaluate(node.getExpression());
    String escapeStrategy = value.asString();

    EscapeMode mode = EscapeMode.computeEscapeMode(escapeStrategy);

    context.pushAutoEscapeMode(mode);
    node.getCommand().apply(this);
View Full Code Here

  @Override
  public void caseAWithCommand(AWithCommand node) {
    setLastPosition(node.getPosition());
    VariableLocator variableLocator = new VariableLocator(expressionEvaluator);
    String withVar = variableLocator.getVariableName(node.getVariable());
    Value value = expressionEvaluator.evaluate(node.getExpression());

    if (value instanceof VariableValue) {
      if (((VariableValue) value).getReference() == null) {
        // With refers to a non-existent variable. Do nothing.
        return;
View Full Code Here

   * node.
   */
  @Override
  public void caseAEachCommand(AEachCommand node) {
    setLastPosition(node.getPosition());
    Value expression = expressionEvaluator.evaluate(node.getExpression());

    if (expression instanceof VariableValue) {
      VariableValue variableValue = (VariableValue) expression;
      Data parent = variableValue.getReference();
      if (parent != null) {
View Full Code Here

   * write the body of the command.
   */
  @Override
  public void caseAAltCommand(AAltCommand node) {
    setLastPosition(node.getPosition());
    Value value = expressionEvaluator.evaluate(node.getExpression());
    if (value.asBoolean()) {
      writeVariable(value);
    } else {
      node.getCommand().apply(this);
    }
  }
View Full Code Here

TOP

Related Classes of com.google.clearsilver.jsilver.values.Value

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.