use of org.apache.sling.scripting.sightly.compiler.commands.OutText in project sling by apache.
the class ElementPlugin method invoke.
@Override
public PluginInvoke invoke(final Expression expression, final PluginCallInfo callInfo, final CompilerContext compilerContext) {
return new DefaultPluginInvoke() {
private final ExpressionNode node = adjustContext(compilerContext, expression, MarkupContext.ELEMENT_NAME, ExpressionContext.ELEMENT).getRoot();
private String tagVar = compilerContext.generateVariable("tagVar");
@Override
public void beforeElement(PushStream stream, String tagName) {
stream.write(new VariableBinding.Start(tagVar, node));
}
@Override
public void beforeTagOpen(PushStream stream) {
stream.write(new Conditional.Start(tagVar, true));
stream.write(new OutText("<"));
stream.write(new OutputVariable(tagVar));
stream.write(Conditional.END);
stream.write(new Conditional.Start(tagVar, false));
}
@Override
public void beforeAttributes(PushStream stream) {
stream.write(Conditional.END);
}
@Override
public void beforeTagClose(PushStream stream, boolean isSelfClosing) {
if (!isSelfClosing) {
stream.write(new Conditional.Start(tagVar, true));
stream.write(new OutText("</"));
stream.write(new OutputVariable(tagVar));
stream.write(new OutText(">"));
stream.write(Conditional.END);
}
stream.write(new Conditional.Start(tagVar, false));
}
@Override
public void afterTagClose(PushStream stream, boolean isSelfClosing) {
stream.write(Conditional.END);
}
@Override
public void afterElement(PushStream stream) {
stream.write(VariableBinding.END);
}
};
}
use of org.apache.sling.scripting.sightly.compiler.commands.OutText in project sling by apache.
the class CoalescingWrites method flushText.
private void flushText() {
if (builder.length() > 0) {
outStream.write(new OutText(builder.toString()));
builder = new StringBuilder();
}
}
Aggregations