*/
protected SoyData applyDirective(
String directiveName, SoyData value, List<SoyData> args, SoyNode node) {
// Get directive.
SoyJavaRuntimePrintDirective directive = soyJavaRuntimeDirectivesMap.get(directiveName);
if (directive == null) {
throw new RenderException(
"Failed to find Soy print directive with name '" + directiveName + "'" +
" (tag " + node.toSourceString() + ")");
}
// TODO: Add a pass to check num args at compile time.
if (! directive.getValidArgsSizes().contains(args.size())) {
throw new RenderException(
"Print directive '" + directiveName + "' used with the wrong number of" +
" arguments (tag " + node.toSourceString() + ").");
}
try {
return directive.apply(value, args);
} catch (RuntimeException e) {
throw new RenderException(String.format(
"Failed in applying directive '%s' in tag \"%s\" due to exception: %s",
directiveName, node.toSourceString(), e.getMessage()));