use of org.apache.sling.scripting.sightly.impl.compiler.frontend.Fragment in project sling by apache.
the class MarkupHandler method requireContext.
private Interpolation requireContext(Interpolation interpolation) {
Interpolation result = new Interpolation();
for (Fragment fragment : interpolation.getFragments()) {
Fragment addedFragment;
if (fragment.isString()) {
addedFragment = fragment;
} else {
if (fragment.getExpression().containsOption(Syntax.CONTEXT_OPTION)) {
addedFragment = fragment;
} else {
String currentTag = currentElementTag();
String warningMessage = String.format("Element %s requires that all expressions have an explicit context specified. " + "The expression will be replaced with an empty string.", currentTag);
stream.warn(new PushStream.StreamMessage(warningMessage, fragment.getExpression().getRawText()));
addedFragment = new Fragment.Expr(new Expression(StringConstant.EMPTY));
}
}
result.addFragment(addedFragment);
}
return result;
}
use of org.apache.sling.scripting.sightly.impl.compiler.frontend.Fragment in project sling by apache.
the class MarkupHandler method attributeChecked.
private Interpolation attributeChecked(String attributeName, Interpolation interpolation) {
if (!MarkupUtils.isSensitiveAttribute(attributeName)) {
return interpolation;
}
Interpolation newInterpolation = new Interpolation();
for (Fragment fragment : interpolation.getFragments()) {
Fragment addedFragment = fragment;
if (fragment.isExpression()) {
Expression expression = fragment.getExpression();
if (!expression.containsOption(Syntax.CONTEXT_OPTION)) {
String warningMessage = String.format("Expressions within the value of attribute %s need to have an explicit context " + "option. The expression will be replaced with an empty string.", attributeName);
stream.warn(new PushStream.StreamMessage(warningMessage, expression.getRawText()));
addedFragment = new Fragment.Text("");
}
}
newInterpolation.addFragment(addedFragment);
}
return newInterpolation;
}
Aggregations