Package com.google.gwt.safehtml.rebind.ParsedHtmlTemplate

Examples of com.google.gwt.safehtml.rebind.ParsedHtmlTemplate.HtmlContext


    assertEquals("[L(<foo>)]", parsed.toString());
  }

  public void testAddParameter() {
    ParsedHtmlTemplate parsed = new ParsedHtmlTemplate();
    parsed.addParameter(new ParameterChunk(new HtmlContext(
        HtmlContext.Type.TEXT), 0));

    List<TemplateChunk> chunks = parsed.getChunks();

    ParameterChunk chunk = (ParameterChunk) chunks.get(0);
View Full Code Here


   */
  public void testAddLiteralAddParameterSequence() {
    ParsedHtmlTemplate parsed = new ParsedHtmlTemplate();

    parsed.addLiteral("<foo>");
    parsed.addParameter(new ParameterChunk(new HtmlContext(
        HtmlContext.Type.TEXT), 0));
    parsed.addLiteral("</foo>");

    List<TemplateChunk> chunks = parsed.getChunks();
    assertEquals(3, chunks.size());
View Full Code Here

   * only a single LiteralChunk.
   */
  public void testAddParameterAddLiteralSequence() {
    ParsedHtmlTemplate parsed = new ParsedHtmlTemplate();

    parsed.addParameter(new ParameterChunk(new HtmlContext(
        HtmlContext.Type.TEXT), 0));
    parsed.addLiteral("<a");
    parsed.addLiteral(" href=\"");
    parsed.addParameter(new ParameterChunk(new HtmlContext(
        HtmlContext.Type.URL_ATTRIBUTE_START, "a", "href"), 1));

    List<TemplateChunk> chunks = parsed.getChunks();
    assertEquals(3, chunks.size());
    Iterator<TemplateChunk> it = chunks.iterator();
View Full Code Here

          "Template variables inside HTML comments are not supported: "
              + getTemplateParsedSoFar());
      throw new UnableToCompleteException();
    } else if (streamHtmlParser.getState().equals(HtmlParser.STATE_TEXT)
        && !streamHtmlParser.inCss()) {
      return new HtmlContext(HtmlContext.Type.TEXT);
    } else if (streamHtmlParser.getState().equals(HtmlParser.STATE_VALUE)) {
      final String tag = streamHtmlParser.getTag();
      final String attribute = streamHtmlParser.getAttribute();
      Preconditions.checkState(!tag.equals(""),
          "streamHtmlParser.getTag() should not be empty  while in "
              + "attribute value context; at %s", getTemplateParsedSoFar());
      Preconditions.checkState(!attribute.equals(""),
          "streamHtmlParser.getAttribute() should not be empty while in "
              + "attribute value context; at %s", getTemplateParsedSoFar());
      if (!streamHtmlParser.isAttributeQuoted()) {
        logger.log(TreeLogger.ERROR,
            "Template variable in unquoted attribute value: "
                + getTemplateParsedSoFar());
        throw new UnableToCompleteException();
      }
      if (streamHtmlParser.isUrlStart()) {
        return new HtmlContext(HtmlContext.Type.URL_START, tag, attribute);
      } else if (streamHtmlParser.inCss()) {
        if (streamHtmlParser.getValueIndex() == 0) {
          return new HtmlContext(HtmlContext.Type.CSS_ATTRIBUTE_START, tag, attribute);
        } else {
          return new HtmlContext(HtmlContext.Type.CSS_ATTRIBUTE, tag, attribute);
        }
      } else {
        return new HtmlContext(
            HtmlContext.Type.ATTRIBUTE_VALUE, tag, attribute);
      }
    } else if (streamHtmlParser.inCss()) {
      return new HtmlContext(HtmlContext.Type.CSS);
    } else if (streamHtmlParser.getState().equals(HtmlParser.STATE_TAG)
        || streamHtmlParser.inAttribute()) {
      logger.log(TreeLogger.ERROR,
          "Template variables in tags or in attribute names are not supported: "
              + getTemplateParsedSoFar());
View Full Code Here

TOP

Related Classes of com.google.gwt.safehtml.rebind.ParsedHtmlTemplate.HtmlContext

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.