package com.wizzardo.http.framework.template.decorator;

import com.wizzardo.http.framework.template.Decorator;
import com.wizzardo.tools.xml.Node;

/**
 * Created by wizzardo on 30.05.15.
 */
public class LayoutTitle implements Decorator {
    @Override
    public void decorate(Node from, Node to) {
        Node title = from.get("html/head/title");
        if (title != null)
            title.parent().children().remove(title);

        replace(to.find("g:layoutTitle"), title);
    }

    @Override
    public int priority() {
        return 1;
    }
}

@@ -426,24 +426,25 @@
 itle);%0A%0A
+%0A
         
 replace(
@@ -439,16 +439,27 @@
     
-replace(
+Node layoutTitle = 
 to.f
@@ -482,15 +482,227 @@
 le%22)
-, title
+;%0A        String defaultTitle = layoutTitle.attr(%22default%22);%0A        if (defaultTitle == null)%0A            defaultTitle = %22%22;%0A%0A        replace(layoutTitle, title != null ? title : new Node(%22title%22).addText(defaultTitle)
 );%0A 

add default value