Package org.apache.shindig.gadgets.templates.tags

Examples of org.apache.shindig.gadgets.templates.tags.TagHandler


    if (styleElement != null) {
      resources.add(TemplateResource.newStyleResource(styleElement.getTextContent(), this));
    }

    Element templateElement = (Element) DomUtil.getFirstNamedChildNode(defElement, TEMPLATE_TAG);
    TagHandler handler = createHandler(tagAttribute.getNodeValue(), templateElement,
        resources.build());
    if (handler != null) {
      handlers.add(handler);
    }
  }
View Full Code Here


    Attr tagAttribute = templateElement.getAttributeNode(TAG_ATTRIBUTE);
    if (tagAttribute == null) {
      throw new TemplateParserException("Missing tag attribute on Template");
    }
   
    TagHandler handler = createHandler(tagAttribute.getNodeValue(), templateElement,
        ImmutableSet.<TemplateResource>of());
    if (handler != null) {
      handlers.add(handler);
    }
  }
View Full Code Here

 
  /**
   * Process conditionals and non-repeat attributes on an element
   */
  private void processElementInner(Node result, Element element) {
    TagHandler handler = registry.getHandlerFor(element);
   
    // An ugly special-case:  <os:Repeat> will re-evaluate the "if" attribute
    // (as it should) for each loop of the repeat.  Don't evaluate it here.
    if (!(handler instanceof RepeatTagHandler)) {
      Attr ifAttribute = element.getAttributeNode(ATTRIBUTE_IF);
      if (ifAttribute != null) {
        if (!evaluate(ifAttribute.getValue(), Boolean.class, false)) {
          return;
        }
      }
    }

    // TODO: the spec is silent on order of evaluation of "cur" relative
    // to "if" and "repeat"
    Attr curAttribute = element.getAttributeNode(ATTRIBUTE_CUR);
    Object oldCur = templateContext.getCur();
    if (curAttribute != null) {
      templateContext.setCur(evaluate(curAttribute.getValue(), Object.class, null));
    }
   
    if (handler != null) {
      handler.process(result, element, this);
    } else {
      // Be careful cloning nodes! If a target node belongs to a different document than the
      // template node then use importNode rather than cloneNode as that avoids side-effects
      // in UserDataHandlers where the cloned template node would belong to its original
      // document before being adopted by the target document.
View Full Code Here

      public TemplateContext getTemplateContext() {
        return context;
      }     
    };
   
    TagHandler handlerWithResources = lib.getTagRegistry()
       .getHandlerFor(new TagRegistry.NSName("#my", "Def"));
    TagHandler handlerWithNoResources = lib.getTagRegistry()
        .getHandlerFor(new TagRegistry.NSName("#my", "Flat"));
   
    Node result = doc.getOwnerDocument().createDocumentFragment();
    Element tag = doc.getOwnerDocument().createElement("test");
   
    // Script and style elements for the library should get registered
    // with the first tag for the whole library
    handlerWithNoResources.process(result, tag, processor);
    assertEquals("<STYLE>libstyle\nlibstyle2</STYLE>" +
        "<JAVASCRIPT>libscript\nlibscript2</JAVASCRIPT>",
        serializeResources(context));

    // Now script and style elements for the tag should get registered
View Full Code Here

  /**
   * Process conditionals and non-repeat attributes on an element
   */
  private void processElementInner(Node result, Element element) {
    TagHandler handler = registry.getHandlerFor(element);

    // An ugly special-case:  <os:Repeat> will re-evaluate the "if" attribute
    // (as it should) for each loop of the repeat.  Don't evaluate it here.
    if (!(handler instanceof RepeatTagHandler)) {
      Attr ifAttribute = element.getAttributeNode(ATTRIBUTE_IF);
      if (ifAttribute != null) {
        if (!evaluate(ifAttribute.getValue(), Boolean.class, false)) {
          return;
        }
      }
    }

    // TODO: the spec is silent on order of evaluation of "cur" relative
    // to "if" and "repeat"
    Attr curAttribute = element.getAttributeNode(ATTRIBUTE_CUR);
    Object oldCur = templateContext.getCur();
    if (curAttribute != null) {
      templateContext.setCur(evaluate(curAttribute.getValue(), Object.class, null));
    }

    if (handler != null) {
      handler.process(result, element, this);
    } else {
      // Be careful cloning nodes! If a target node belongs to a different document than the
      // template node then use importNode rather than cloneNode as that avoids side-effects
      // in UserDataHandlers where the cloned template node would belong to its original
      // document before being adopted by the target document.
View Full Code Here

      public TemplateContext getTemplateContext() {
        return context;
      }     
    };
   
    TagHandler handlerWithResources = lib.getTagRegistry()
       .getHandlerFor(new TagRegistry.NSName("#my", "Def"));
    TagHandler handlerWithNoResources = lib.getTagRegistry()
        .getHandlerFor(new TagRegistry.NSName("#my", "Flat"));
   
    Node result = doc.getOwnerDocument().createDocumentFragment();
    Element tag = doc.getOwnerDocument().createElement("test");
   
    // Script and style elements for the library should get registered
    // with the first tag for the whole library
    handlerWithNoResources.process(result, tag, processor);
    assertEquals("<STYLE>libstyle\nlibstyle2</STYLE>" +
                 "<JAVASCRIPT>libscript\nlibscript2</JAVASCRIPT>",
                 serializeResources(context));

    // Now script and style elements for the tag should get registered
View Full Code Here

    if (styleElement != null) {
      resources.add(TemplateResource.newStyleResource(styleElement.getTextContent(), this));
    }

    Element templateElement = (Element) DomUtil.getFirstNamedChildNode(defElement, TEMPLATE_TAG);
    TagHandler handler = createHandler(tagAttribute.getNodeValue(), templateElement,
        resources.build());
    if (handler != null) {
      handlers.add(handler);
    }
  }
View Full Code Here

    Attr tagAttribute = templateElement.getAttributeNode(TAG_ATTRIBUTE);
    if (tagAttribute == null) {
      throw new TemplateParserException("Missing tag attribute on Template");
    }

    TagHandler handler = createHandler(tagAttribute.getNodeValue(), templateElement,
        ImmutableSet.<TemplateResource>of());
    if (handler != null) {
      handlers.add(handler);
    }
  }
View Full Code Here

  /**
   * Process conditionals and non-repeat attributes on an element
   */
  private void processElementInner(Node result, Element element) {
    TagHandler handler = registry.getHandlerFor(element);

    // An ugly special-case:  <os:Repeat> will re-evaluate the "if" attribute
    // (as it should) for each loop of the repeat.  Don't evaluate it here.
    if (!(handler instanceof RepeatTagHandler)) {
      Attr ifAttribute = element.getAttributeNode(ATTRIBUTE_IF);
      if (ifAttribute != null) {
        if (!evaluate(ifAttribute.getValue(), Boolean.class, false)) {
          return;
        }
      }
    }

    // TODO: the spec is silent on order of evaluation of "cur" relative
    // to "if" and "repeat"
    Attr curAttribute = element.getAttributeNode(ATTRIBUTE_CUR);
    Object oldCur = templateContext.getCur();
    if (curAttribute != null) {
      templateContext.setCur(evaluate(curAttribute.getValue(), Object.class, null));
    }

    if (handler != null) {
      handler.process(result, element, this);
    } else {
      // Be careful cloning nodes! If a target node belongs to a different document than the
      // template node then use importNode rather than cloneNode as that avoids side-effects
      // in UserDataHandlers where the cloned template node would belong to its original
      // document before being adopted by the target document.
View Full Code Here

    if (styleElement != null) {
      resources.add(TemplateResource.newStyleResource(styleElement.getTextContent(), this));
    }

    Element templateElement = (Element) DomUtil.getFirstNamedChildNode(defElement, TEMPLATE_TAG);
    TagHandler handler = createHandler(tagAttribute.getNodeValue(), templateElement,
        resources.build());
    if (handler != null) {
      handlers.add(handler);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.templates.tags.TagHandler

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.