use of org.apache.sling.scripting.sightly.compiler.SightlyCompilerException in project sling by apache.
the class ExpressionParser method parseInterpolation.
/**
* Parses the expression string.
*
* @param expressionString as defined by the HTL spec (https://github.com/Adobe-Marketing-Cloud/htl-spec/blob/master/SPECIFICATION.md)
* @return Parsed Expression object
* @throws NullPointerException is the given exprString is null
* @throws SightlyCompilerException if an error occurs while parsing the expression
*/
public Interpolation parseInterpolation(String expressionString) throws SightlyCompilerException {
SightlyParser parser = createParser(expressionString);
try {
Interpolation interpolation = parser.interpolation().interp;
interpolation.setContent(expressionString);
return interpolation;
} catch (RecognitionException e) {
throw new SightlyCompilerException(e);
}
}
use of org.apache.sling.scripting.sightly.compiler.SightlyCompilerException in project sling by apache.
the class CallPlugin method invoke.
@Override
public PluginInvoke invoke(final Expression expression, final PluginCallInfo callInfo, final CompilerContext compilerContext) {
if (callInfo.getArguments().length > 0) {
throw new SightlyCompilerException("Call plugin should have no arguments.", "data-sly-call." + callInfo.getArguments()[0]);
}
return new DefaultPluginInvoke() {
@Override
public void beforeChildren(PushStream stream) {
String templateVar = compilerContext.generateVariable("templateVar");
String argsVar = compilerContext.generateVariable("templateOptions");
MapLiteral args = new MapLiteral(expression.getOptions());
stream.write(new VariableBinding.Start(templateVar, expression.getRoot()));
stream.write(new VariableBinding.Start(argsVar, args));
stream.write(new Procedure.Call(templateVar, argsVar));
stream.write(VariableBinding.END);
stream.write(VariableBinding.END);
//ignoring everything else
Patterns.beginStreamIgnore(stream);
}
@Override
public void afterChildren(PushStream stream) {
Patterns.endStreamIgnore(stream);
}
};
}
Aggregations