Package com.google.caja.render

Examples of com.google.caja.render.Concatenator


    switch (config.renderer()) {
      case PRETTY:
        tc = module.makeRenderer(out, exHandler);
        break;
      case MINIFY:
        tc = new JsMinimalPrinter(new Concatenator(out,  exHandler));
        break;
      default:
        throw new SomethingWidgyHappenedError(
            "Unrecognized renderer: " + config.renderer());
    }
View Full Code Here


                    "html", renderDomAsJsStringLiteral(node)))))));
  }

  private static StringLiteral renderDomAsJsStringLiteral(Node node) {
    StringBuilder stringBuilder = new StringBuilder();
    TokenConsumer tc = new Concatenator(stringBuilder);
    Nodes.render(node, new RenderContext(tc));
    return StringLiteral.valueOf(Nodes.getFilePositionFor(node), stringBuilder);
  }
View Full Code Here

  }

  private String render(CajoledModule module,
                        Expression callbackExpression) {
    StringBuilder out = new StringBuilder();
    TokenConsumer tc = new JsPrettyPrinter(new Concatenator(out, exHandler));
    module.render(callbackExpression, new RenderContext(tc));
    tc.noMoreTokens();
    return out.toString();
  }
View Full Code Here

  private void assertRenderedForm(String golden, String cssInput)
      throws Exception {
    CssTree.StyleSheet stylesheet = css(fromString(cssInput));

    StringBuilder sb = new StringBuilder();
    CssPrettyPrinter csspp = new CssPrettyPrinter(new Concatenator(sb));
    RenderContext rc = new RenderContext(csspp);
    stylesheet.render(rc);
    csspp.noMoreTokens();
    String actual = sb.toString();
View Full Code Here

    DocumentFragment fragment = xmlFragment(fromString(
        "<svg:foo><xml:bar/></svg:foo>"));
    Namespaces ns = new Namespaces(
        Namespaces.HTML_DEFAULT, "svg", Namespaces.XML_NAMESPACE_URI);
    StringBuilder sb = new StringBuilder();
    RenderContext rc = new RenderContext(new Concatenator(sb))
        .withMarkupRenderMode(MarkupRenderMode.XML);
    Nodes.render(fragment, ns, rc);
    rc.getOut().noMoreTokens();
    assertEquals(
        ""
View Full Code Here

    assertEquals("<span title=\"Howdy\"></span>", Nodes.render(el));

    Namespaces ns = new Namespaces(
        Namespaces.HTML_DEFAULT, "html", Namespaces.HTML_NAMESPACE_URI);
    StringBuilder sb = new StringBuilder();
    RenderContext rc = new RenderContext(new Concatenator(sb))
        .withMarkupRenderMode(MarkupRenderMode.HTML);
    Nodes.render(el, ns, rc);
    rc.getOut().noMoreTokens();
    assertEquals("<html:span title=\"Howdy\"></html:span>", sb.toString());
  }
View Full Code Here

            DoctypeMaker.parse(docType), null);
        Element el = html(fromString("<html><b>my text</b></html>"));
        doc.appendChild(doc.adoptNode(el));

        StringBuilder sb = new StringBuilder();
        RenderContext rc = new RenderContext(new Concatenator(sb))
        .withMarkupRenderMode(expectedPair.a);
        Nodes.render(doc.getDoctype(), el, Namespaces.HTML_DEFAULT, rc);
        rc.getOut().noMoreTokens();
        String actual = sb.toString();
        MoreAsserts.assertStartsWith(docType, actual);
View Full Code Here

    for (Message msg : mq.getMessages()) {
      msg.format(mc, System.err);
      System.err.println();
    }
    JsMinimalPrinter printer = new JsMinimalPrinter(
        new Concatenator(System.out, null));
    RenderContext rc = new RenderContext(printer)
        .withPropertyNameQuotingMode(PropertyNameQuotingMode.NO_QUOTES);
    if (out instanceof Block) {
      ((Block) out).renderBody(rc);
    } else {
View Full Code Here

        getModuleBody().propertyWithName("instantiate")).getValueExpr();
  }

  public final TokenConsumer makeRenderer(
      Appendable out, Callback<IOException> exHandler) {
    return new JsPrettyPrinter(new Concatenator(out, exHandler));
  }
View Full Code Here

  private static String render(ParseTreeNode n, boolean minify) {
    StringBuilder buf = new StringBuilder();
    TokenConsumer tc;
    if (minify) {
      tc = new JsMinimalPrinter(new Concatenator(buf));
    } else {
      tc = new JsPrettyPrinter(new Concatenator(buf));
    }
    RenderContext rc = new RenderContext(tc);
    n.render(rc);
    tc.noMoreTokens();
    return buf.toString();
View Full Code Here

TOP

Related Classes of com.google.caja.render.Concatenator

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.