Package com.google.clearsilver.jsilver.data

Examples of com.google.clearsilver.jsilver.data.Data


   */
  public Value execute(Value... args) {
    Value value = args[0];
    if (value instanceof VariableValue) {
      VariableValue variableValue = (VariableValue) value;
      Data variable = variableValue.getReference();
      if (variable != null) {
        return literalValue(variable.getSymlink().getName(), variableValue.getEscapeMode(),
            variableValue.isPartiallyEscaped());
      }
    }
    return literalConstant("", value);
  }
View Full Code Here


    VariableValue arg = (VariableValue) args[0];
    if (arg.getReference() == null) {
      return literalConstant(false, arg);
    }

    Data thisNode = arg.getReference().getSymlink();
    return literalConstant(thisNode.isFirstSibling(), arg);
  }
View Full Code Here

    // Load resources from filesystem, relative to the current directory.
    JSilver jSilver = new JSilver(new FileSystemResourceLoader("."));

    // Load data.
    Data data = jSilver.createData();
    for (int i = 1; i < args.length; i++) {
      jSilver.loadData(args[i], data);
    }

    // Render template to System.out.
View Full Code Here

    // Load resources (e.g. templates) from classpath, along side this class.
    JSilver jSilver = new JSilver(new ClassResourceLoader(Iterate.class));

    // Set up some data.
    Data data = jSilver.createData();
    data.setValue("query", "Fruit");
    data.setValue("results.0.title", "Banana");
    data.setValue("results.0.url", "http://banana.com/");
    data.setValue("results.1.title", "Apple");
    data.setValue("results.1.url", "http://apple.com/");
    data.setValue("results.2.title", "Lemon");
    data.setValue("results.2.url", "http://lemon.com/");

    // Render template to System.out.
    jSilver.render("iterate.cs", data, System.out);
  }
View Full Code Here

    // Load resources (e.g. templates) from classpath, along side this class.
    JSilver jSilver = new JSilver(new ClassResourceLoader(HelloWorld.class));

    // Set up some data.
    Data data = jSilver.createData();
    data.setValue("name.first", "Mr");
    data.setValue("name.last", "Man");

    // Render template to System.out.
    jSilver.render("hello-world.cs", data, System.out);
  }
View Full Code Here

    throw new UnsupportedOperationException("TBD");
  }

  @Override
  public HDF getObj(String hdfpath) {
    Data d = data.getChild(hdfpath);
    return d == null ? null : new JHdf(d, dataFactory, loadPathCache, options);
  }
View Full Code Here

    return d == null ? null : new JHdf(d, dataFactory, loadPathCache, options);
  }

  @Override
  public HDF getChild(String hdfpath) {
    Data d = data.getChild(hdfpath);
    if (d == null) {
      return null;
    }
    for (Data child : d.getChildren()) {
      if (child.isFirstSibling()) {
        return new JHdf(child, dataFactory, loadPathCache, options);
      } else {
        // The first child returned should be the first sibling. Throw an error
        // if not.
View Full Code Here

    return null;
  }

  @Override
  public HDF getRootObj() {
    Data root = data.getRoot();
    if (root == data) {
      return this;
    } else {
      return new JHdf(root, dataFactory, loadPathCache, options);
    }
View Full Code Here

    return null;
  }

  @Override
  public HDF objNext() {
    Data next = data.getNextSibling();
    return next == null ? null : new JHdf(next, dataFactory, loadPathCache, options);
  }
View Full Code Here

    }
    template = getJSilver().getTemplateLoader().createTemp("parseStr", content, getEscapeMode());
  }

  private EscapeMode getEscapeMode() {
    Data data = localHdf.getData();
    return getJSilver().getEscapeMode(data);
  }
View Full Code Here

TOP

Related Classes of com.google.clearsilver.jsilver.data.Data

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.