commit b17bbb39975f29c9143188a702ad3ee4d8e05829
Author:     joehni <[email protected]>
AuthorDate: Wed, 1 May 2013 16:50:08 +0200
Commit:     joehni <[email protected]>
CommitDate: Wed, 1 May 2013 16:50:08 +0200

    Make class attribute value configurable.

diff --git 
a/xsite-core/src/main/java/org/codehaus/xsite/extractors/sitemesh/rules/AddFirstChildClassToHeader.java
 
b/xsite-core/src/main/java/org/codehaus/xsite/extractors/sitemesh/rules/AddFirstChildClassToHeader.java
index 425e037..40cc3c1 100644
--- 
a/xsite-core/src/main/java/org/codehaus/xsite/extractors/sitemesh/rules/AddFirstChildClassToHeader.java
+++ 
b/xsite-core/src/main/java/org/codehaus/xsite/extractors/sitemesh/rules/AddFirstChildClassToHeader.java
@@ -5,20 +5,27 @@ import com.opensymphony.module.sitemesh.html.CustomTag;
 import com.opensymphony.module.sitemesh.html.Tag;
 
 /**
- * Rule for HTMLProcessor that adds class=""FirstChild" to the first header of 
the body if it is the first element.
+ * Rule for HTMLProcessor that adds a class attribute to the first header of 
the body if it is the first element.
+ * The attribute value is by default "FirstChild".
  */
 public class AddFirstChildClassToHeader extends BasicRule {
     private boolean firstChild = false;
+       private final String className;
 
     public AddFirstChildClassToHeader() {
+       this("FirstChild");
+    }
+
+    public AddFirstChildClassToHeader(String className) {
        super(new String[]{"p", "div", "h1", "h2", "h3", "h4", "h5", "h6"});
+               this.className = className;
     }
 
     public void process(Tag tag) {
         if (!firstChild) {
             if (tag.getName().charAt(0) == 'h') {
                 final CustomTag customTag = new CustomTag(tag);
-                customTag.addAttribute("class", "FirstChild");
+                customTag.addAttribute("class", className);
                 tag = customTag;
             }
             firstChild = true;



Reply via email to