Package com.github.dandelion.core.html

Examples of com.github.dandelion.core.html.HtmlTag


* @since 0.2.0
*/
public class HtmlUtils {

  public static HtmlTag transformAsset(Asset asset) {
    HtmlTag tag;
    switch (asset.getType()) {
    case css:
      tag = new LinkTag(asset.getFinalLocation());
      break;
    case js:
      tag = new ScriptTag(asset.getFinalLocation());
      break;
    default:
      tag = null;
    }
    if (tag != null) {
      tag.addAttributesOnlyName(asset.getAttributesOnlyName());
      tag.addAttributes(asset.getAttributes());
    }
    return tag;
  }
View Full Code Here


      Set<Asset> assetsHead = new AssetQuery(request, context).withPosition(AssetDomPosition.head).perform();

      if (!assetsHead.isEmpty()) {
        StringBuilder htmlHead = new StringBuilder();
        for (Asset asset : assetsHead) {
          HtmlTag tag = HtmlUtils.transformAsset(asset);
          htmlHead.append(tag.toHtml());
          htmlHead.append('\n');
        }

        html = html.replace("</head>", htmlHead + "\n</head>");
      }

      Set<Asset> assetsBody = new AssetQuery(request, context).withPosition(AssetDomPosition.body).perform();

      if (!assetsBody.isEmpty()) {
        StringBuilder htmlBody = new StringBuilder();
        for (Asset asset : assetsBody) {
          HtmlTag tag = HtmlUtils.transformAsset(asset);
          htmlBody.append(tag.toHtml());
          htmlBody.append('\n');
        }
        html = html.replace("</body>", htmlBody + "</body>");
      }
View Full Code Here

TOP

Related Classes of com.github.dandelion.core.html.HtmlTag

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.