com.hubspot.jinjava.loader.CascadingResourceLocator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jinjava Show documentation
Show all versions of jinjava Show documentation
Jinja templating engine implemented in Java
package com.hubspot.jinjava.loader;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Arrays;
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
public class CascadingResourceLocator implements ResourceLocator {
private Iterable locators;
public CascadingResourceLocator(ResourceLocator... locators) {
this.locators = Arrays.asList(locators);
}
@Override
public String getString(String fullName, Charset encoding,
JinjavaInterpreter interpreter) throws IOException {
for (ResourceLocator locator : locators) {
try {
return locator.getString(fullName, encoding, interpreter);
} catch (ResourceNotFoundException e) { /* */
}
}
throw new ResourceNotFoundException("Couldn't find resource: " + fullName);
}
}