use of org.apache.sling.scripting.sightly.render.RuntimeObjectModel in project sling by apache.
the class I18nRuntimeExtension method call.
@Override
public Object call(final RenderContext renderContext, Object... arguments) {
ExtensionUtils.checkArgumentCount(RuntimeFunction.I18N, arguments, 2);
RuntimeObjectModel runtimeObjectModel = renderContext.getObjectModel();
String text = runtimeObjectModel.toString(arguments[0]);
Map<String, Object> options = (Map<String, Object>) arguments[1];
String locale = runtimeObjectModel.toString(options.get("locale"));
String hint = runtimeObjectModel.toString(options.get("hint"));
String basename = runtimeObjectModel.toString(options.get("basename"));
final Bindings bindings = renderContext.getBindings();
return get(bindings, text, locale, basename, hint);
}
use of org.apache.sling.scripting.sightly.render.RuntimeObjectModel in project sling by apache.
the class IncludeRuntimeExtension method call.
@Override
public Object call(final RenderContext renderContext, Object... arguments) {
ExtensionUtils.checkArgumentCount(RuntimeFunction.INCLUDE, arguments, 2);
RuntimeObjectModel runtimeObjectModel = renderContext.getObjectModel();
String originalPath = runtimeObjectModel.toString(arguments[0]);
Map options = (Map) arguments[1];
String path = buildPath(originalPath, options);
StringWriter output = new StringWriter();
final Bindings bindings = renderContext.getBindings();
SlingHttpServletRequest request = BindingsUtils.getRequest(bindings);
Map originalAttributes = ExtensionUtils.setRequestAttributes(request, (Map) options.remove(OPTION_REQUEST_ATTRIBUTES));
includeScript(bindings, path, new PrintWriter(output));
ExtensionUtils.setRequestAttributes(request, originalAttributes);
return output.toString();
}
Aggregations