Package com.google.clearsilver.jsilver.values

Examples of com.google.clearsilver.jsilver.values.Value.asString()


  public Value execute(Value... args) {
    Value left = args[0];
    Value right = args[1];
    EscapeMode mode = EscapeMode.combineModes(left.getEscapeMode(), right.getEscapeMode());
    return literalValue(left.asString() + right.asString(), mode, left.isPartiallyEscaped()
        || right.isPartiallyEscaped());
  }

}
View Full Code Here


   * @param args A single string value
   * @return Length as number value
   */
  public Value execute(Value... args) {
    Value value = args[0];
    return literalConstant(value.asString().length(), value);
  }

}
View Full Code Here

   * @return Position of the start of substring (or -1 if not found) as number value
   */
  public Value execute(Value... args) {
    Value fullStringValue = args[0];
    Value subStringValue = args[1];
    return literalConstant(fullStringValue.asString().indexOf(subStringValue.asString()),
        fullStringValue, subStringValue);
  }
}
View Full Code Here

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

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

  /**
   * <?cs lvar:blah > command. Evaluate expression and execute commands within.
   */
 
View Full Code Here

    // 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

    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());
View Full Code Here

   */
  @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

   */
  @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

   */
  private void include(PExpression expression, boolean ignoreMissingFile) {
    // Evaluate expression.
    Value path = expressionEvaluator.evaluate(expression);

    String templateName = path.asString();
    if (!context.pushIncludeStackEntry(templateName)) {
      throw new JSilverInterpreterException(createIncludeLoopErrorMessage(templateName, context
          .getIncludedTemplateNames()));
    }

View Full Code Here

  @Override
  public void caseAExpandVariable(AExpandVariable node) {
    node.getParent().apply(this);
    Value value = expressionEvaluator.evaluate(node.getChild());
    descendVariable(value.asString());
  }

  private void descendVariable(String name) {
    if (currentName.length() != 0) {
      currentName.append('.');
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.