Package com.google.caja.render

Examples of com.google.caja.render.Concatenator


      CajoledModule outputJs = passed ? compiler.getJavascript() : null;

      StringBuilder jsOut = new StringBuilder();
      TokenConsumer printer;
      if ("1".equals(req.getParam("debug"))) {
        printer = new JsPrettyPrinter(new Concatenator(jsOut));
      } else {
        printer = new JsMinimalPrinter(new Concatenator(jsOut));
      }

      RenderContext renderContext = new RenderContext(printer).withEmbeddable(true);

      if (outputJs != null) {
View Full Code Here


  }

  private String renderJs(CajoledModule cajoled, boolean debug) {
    StringBuilder rendered = new StringBuilder();
    TokenConsumer tc = debug
        ? new JsPrettyPrinter(new Concatenator(rendered))
        : new JsMinimalPrinter(new Concatenator(rendered));
    cajoled.render(new RenderContext(tc)
        .withAsciiOnly(true)
        .withEmbeddable(true));
    tc.noMoreTokens();
    return rendered.toString();
View Full Code Here

  }

  private static class CajaHtmlSerializer implements HtmlSerializer {
    public String serialize(Document doc) {
      StringWriter sw = HtmlSerialization.createWriter(doc);
      return Nodes.render(doc, new RenderContext(new Concatenator(sw, null)).asXml());
    }
View Full Code Here

    return writer.toString();
  }

  /** Serialize a stylesheet to a Writer. */
  public void serialize(CssTree.StyleSheet styleSheet, Writer writer) {
    CssPrettyPrinter cssPrinter = new CssPrettyPrinter(new Concatenator(writer, null));
    styleSheet.render(new RenderContext(cssPrinter));
    cssPrinter.noMoreTokens();
  }
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

        Element el = (Element)getOnlyChild(
            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

        getClass(), getFilePosition(), getValue(), children());
  }

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

  }

  private static String render(Node node, MarkupRenderMode renderMode,
      boolean renderUnsafe) {
    StringBuilder sb = new StringBuilder();
    RenderContext rc = new RenderContext(new Concatenator(sb, null))
        .withMarkupRenderMode(renderMode);
    render(node, rc, renderUnsafe);
    rc.getOut().noMoreTokens();
    return sb.toString();
  }
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

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.