Search in sources :

Example 1 with PluginInvoke

use of org.apache.sling.scripting.sightly.impl.plugin.PluginInvoke in project sling by apache.

the class MarkupHandler method onCloseTag.

public void onCloseTag(String markup) {
    ElementContext context = elementStack.pop();
    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);
}
Also used : PluginInvoke(org.apache.sling.scripting.sightly.impl.plugin.PluginInvoke) ElementContext(org.apache.sling.scripting.sightly.impl.compiler.frontend.ElementContext)

Example 2 with PluginInvoke

use of org.apache.sling.scripting.sightly.impl.plugin.PluginInvoke in project sling by apache.

the class MarkupHandler method onOpenTagEnd.

public void onOpenTagEnd(String markup) {
    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);
    traverseAttributes(context, invoke);
    invoke.afterAttributes(stream);
    out(markup);
    invoke.afterTagOpen(stream);
    if (slyTag) {
        Patterns.endStreamIgnore(stream);
    }
    invoke.beforeChildren(stream);
}
Also used : PluginInvoke(org.apache.sling.scripting.sightly.impl.plugin.PluginInvoke) ElementContext(org.apache.sling.scripting.sightly.impl.compiler.frontend.ElementContext)

Example 3 with PluginInvoke

use of org.apache.sling.scripting.sightly.impl.plugin.PluginInvoke in project sling by apache.

the class MarkupHandler method handlePlugin.

private void handlePlugin(String name, String value, ElementContext context) {
    PluginCallInfo callInfo = Syntax.parsePluginAttribute(name);
    if (callInfo != null) {
        Plugin plugin = obtainPlugin(callInfo.getName());
        ExpressionContext expressionContext = ExpressionContext.getContextForPlugin(plugin.name());
        Expression expr = expressionWrapper.transform(expressionParser.parseInterpolation(value), null, expressionContext);
        PluginInvoke invoke = plugin.invoke(expr, callInfo, compilerContext);
        context.addPlugin(invoke, plugin.priority());
        context.addPluginCall(name, callInfo, expr);
    }
}
Also used : PluginCallInfo(org.apache.sling.scripting.sightly.impl.plugin.PluginCallInfo) PluginInvoke(org.apache.sling.scripting.sightly.impl.plugin.PluginInvoke) ExpressionContext(org.apache.sling.scripting.sightly.impl.filter.ExpressionContext) Expression(org.apache.sling.scripting.sightly.compiler.expression.Expression) Plugin(org.apache.sling.scripting.sightly.impl.plugin.Plugin)

Example 4 with PluginInvoke

use of org.apache.sling.scripting.sightly.impl.plugin.PluginInvoke in project sling by apache.

the class ElementContext method pluginInvoke.

public PluginInvoke pluginInvoke() {
    if (aggregateInvoke == null) {
        Collections.sort(invokeList);
        ArrayList<PluginInvoke> result = new ArrayList<>();
        for (PrioritizedInvoke prioritizedInvoke : invokeList) {
            result.add(prioritizedInvoke.invoke);
        }
        aggregateInvoke = new AggregatePluginInvoke(result);
    }
    return aggregateInvoke;
}
Also used : PluginInvoke(org.apache.sling.scripting.sightly.impl.plugin.PluginInvoke) AggregatePluginInvoke(org.apache.sling.scripting.sightly.impl.plugin.AggregatePluginInvoke) AggregatePluginInvoke(org.apache.sling.scripting.sightly.impl.plugin.AggregatePluginInvoke) ArrayList(java.util.ArrayList)

Aggregations

PluginInvoke (org.apache.sling.scripting.sightly.impl.plugin.PluginInvoke)4 ElementContext (org.apache.sling.scripting.sightly.impl.compiler.frontend.ElementContext)2 ArrayList (java.util.ArrayList)1 Expression (org.apache.sling.scripting.sightly.compiler.expression.Expression)1 ExpressionContext (org.apache.sling.scripting.sightly.impl.filter.ExpressionContext)1 AggregatePluginInvoke (org.apache.sling.scripting.sightly.impl.plugin.AggregatePluginInvoke)1 Plugin (org.apache.sling.scripting.sightly.impl.plugin.Plugin)1 PluginCallInfo (org.apache.sling.scripting.sightly.impl.plugin.PluginCallInfo)1