sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1657852 - in /sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl: html/dom/MarkupHandler.java plugin/UnwrapPlugin.java
Date Fri, 06 Feb 2015 15:06:20 GMT
Author: fmeschbe
Date: Fri Feb  6 15:06:19 2015
New Revision: 1657852

URL: http://svn.apache.org/r1657852
Log:
SLING-4355 Implement support for the 'sly' HTML tag

(Apply patch by Radu Cotescu, thanks a lot)

Modified:
    sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/html/dom/MarkupHandler.java
    sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/plugin/UnwrapPlugin.java

Modified: sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/html/dom/MarkupHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/html/dom/MarkupHandler.java?rev=1657852&r1=1657851&r2=1657852&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/html/dom/MarkupHandler.java
(original)
+++ sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/html/dom/MarkupHandler.java
Fri Feb  6 15:06:19 2015
@@ -31,6 +31,7 @@ import org.apache.sling.scripting.sightl
 import org.apache.sling.scripting.sightly.impl.compiler.frontend.ExpressionWrapper;
 import org.apache.sling.scripting.sightly.impl.compiler.frontend.Fragment;
 import org.apache.sling.scripting.sightly.impl.compiler.frontend.Interpolation;
+import org.apache.sling.scripting.sightly.impl.compiler.ris.command.Patterns;
 import org.apache.sling.scripting.sightly.impl.filter.Filter;
 import org.apache.sling.scripting.sightly.impl.compiler.expression.Expression;
 import org.apache.sling.scripting.sightly.impl.compiler.expression.ExpressionNode;
@@ -94,6 +95,10 @@ public class MarkupHandler {
         ElementContext context = elementStack.peek();
         PluginInvoke invoke = context.pluginInvoke();
         invoke.beforeElement(stream, context.getTagName());
+        boolean slyTag = "sly".equalsIgnoreCase(context.getTagName());
+        if (slyTag) {
+            Patterns.beginStreamIgnore(stream);
+        }
         invoke.beforeTagOpen(stream);
         out(context.getOpenTagStartMarkup());
         invoke.beforeAttributes(stream);
@@ -101,6 +106,9 @@ public class MarkupHandler {
         invoke.afterAttributes(stream);
         out(markup);
         invoke.afterTagOpen(stream);
+        if (slyTag) {
+            Patterns.endStreamIgnore(stream);
+        }
         invoke.beforeChildren(stream);
     }
 
@@ -249,9 +257,16 @@ public class MarkupHandler {
         PluginInvoke invoke = context.pluginInvoke();
         invoke.afterChildren(stream);
         boolean selfClosingTag = StringUtils.isEmpty(markup);
+        boolean slyTag = "sly".equalsIgnoreCase(context.getTagName());
+        if (slyTag) {
+            Patterns.beginStreamIgnore(stream);
+        }
         invoke.beforeTagClose(stream, selfClosingTag);
         out(markup);
         invoke.afterTagClose(stream, selfClosingTag);
+        if (slyTag) {
+            Patterns.endStreamIgnore(stream);
+        }
         invoke.afterElement(stream);
     }
 

Modified: sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/plugin/UnwrapPlugin.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/plugin/UnwrapPlugin.java?rev=1657852&r1=1657851&r2=1657852&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/plugin/UnwrapPlugin.java
(original)
+++ sling/trunk/contrib/scripting/sightly/engine/src/main/java/org/apache/sling/scripting/sightly/impl/plugin/UnwrapPlugin.java
Fri Feb  6 15:06:19 2015
@@ -22,15 +22,16 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Properties;
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.scripting.sightly.impl.compiler.common.DefaultPluginInvoke;
 import org.apache.sling.scripting.sightly.impl.compiler.expression.Expression;
 import org.apache.sling.scripting.sightly.impl.compiler.expression.ExpressionNode;
 import org.apache.sling.scripting.sightly.impl.compiler.expression.node.BooleanConstant;
 import org.apache.sling.scripting.sightly.impl.compiler.expression.node.StringConstant;
+import org.apache.sling.scripting.sightly.impl.compiler.frontend.CompilerContext;
 import org.apache.sling.scripting.sightly.impl.compiler.ris.Command;
 import org.apache.sling.scripting.sightly.impl.compiler.ris.command.Conditional;
+import org.apache.sling.scripting.sightly.impl.compiler.ris.command.Patterns;
 import org.apache.sling.scripting.sightly.impl.compiler.ris.command.VariableBinding;
-import org.apache.sling.scripting.sightly.impl.compiler.common.DefaultPluginInvoke;
-import org.apache.sling.scripting.sightly.impl.compiler.frontend.CompilerContext;
 import org.apache.sling.scripting.sightly.impl.compiler.util.stream.PushStream;
 
 /**
@@ -50,30 +51,44 @@ public class UnwrapPlugin extends Plugin
 
             private final String variable = compilerContext.generateVariable("unwrapCondition");
             private final Command unwrapTest = new Conditional.Start(variable, false);
+            private boolean isSlyTag = false;
 
             @Override
             public void beforeElement(PushStream stream, String tagName) {
+                isSlyTag = "sly".equals(tagName.toLowerCase());
                 stream.emit(new VariableBinding.Start(variable, testNode()));
             }
 
             @Override
             public void beforeTagOpen(PushStream stream) {
+                if (isSlyTag) {
+                    Patterns.endStreamIgnore(stream);
+                }
                 stream.emit(unwrapTest);
             }
 
             @Override
             public void afterTagOpen(PushStream stream) {
                 stream.emit(Conditional.END);
+                if (isSlyTag) {
+                    Patterns.beginStreamIgnore(stream);
+                }
             }
 
             @Override
             public void beforeTagClose(PushStream stream, boolean isSelfClosing) {
+                if (isSlyTag) {
+                    Patterns.endStreamIgnore(stream);
+                }
                 stream.emit(unwrapTest);
             }
 
             @Override
             public void afterTagClose(PushStream stream, boolean isSelfClosing) {
                 stream.emit(Conditional.END);
+                if (isSlyTag) {
+                    Patterns.beginStreamIgnore(stream);
+                }
             }
 
             @Override



Mime
View raw message