use of org.rythmengine.RythmEngine in project docx4j-template by vindell.
the class WordprocessingMLRythmTemplate method getInternalEngine.
protected RythmEngine getInternalEngine() throws IOException {
Properties props = ConfigUtils.filterWithPrefix("docx4j.rythm.", "docx4j.rythm.", Docx4jProperties.getProperties(), false);
props.put("engine.mode", Rythm.Mode.valueOf(props.getProperty("engine.mode", "dev")));
props.put("log.enabled", false);
props.put("feature.smart_escape.enabled", false);
props.put("feature.transform.enabled", false);
try {
props.put("home.template", Rythm.class.getResource(props.getProperty("home.template")).toURI().toURL().getFile());
} catch (URISyntaxException e) {
// ignore
props.put("home.tmp", "/");
}
props.put("codegen.dynamic_exp.enabled", true);
props.put("built_in.code_type", "false");
props.put("built_in.transformer", "false");
props.put("engine.file_write", "false");
props.put("codegen.compact.enabled", "false");
return new RythmEngine(props);
}
use of org.rythmengine.RythmEngine in project actframework by actframework.
the class RythmView method getEngine.
public RythmEngine getEngine(App app) {
RythmEngine engine = engines.get(app);
if (null == engine) {
RythmEngine newEngine = createEngine(app);
engine = engines.putIfAbsent(app, newEngine);
if (null == engine) {
engine = newEngine;
} else {
newEngine.shutdown();
}
}
return engine;
}
use of org.rythmengine.RythmEngine in project actframework by actframework.
the class RythmView method createEngine.
private RythmEngine createEngine(App app) {
AppConfig config = app.config();
Properties p = new Properties();
p.put(ENGINE_MODE.getKey(), Act.mode().isDev() ? Rythm.Mode.dev : Rythm.Mode.prod);
p.put(ENGINE_PLUGIN_VERSION.getKey(), Act.VERSION.getVersion());
p.put(ENGINE_CLASS_LOADER_PARENT_IMPL.getKey(), app.classLoader());
p.put(HOME_TMP.getKey(), createTempHome(app));
Map map = config.rawConfiguration();
for (Object k : map.keySet()) {
String key = k.toString();
if (key.startsWith("rythm.")) {
p.put(key, map.get(key));
}
}
String appRestricted = p.getProperty("rythm.sandbox.restricted_classes", "");
appRestricted += ";act.*";
p.put(SANDBOX_RESTRICTED_CLASS.getKey(), appRestricted);
p.put(HOME_TEMPLATE.getKey(), templateRootDir());
p.put(CODEGEN_SOURCE_CODE_ENHANCER.getKey(), new ISourceCodeEnhancer() {
@Override
public List<String> imports() {
return C.list();
}
@Override
public String sourceCode() {
return "";
}
@Override
public Map<String, ?> getRenderArgDescriptions() {
Map<String, String> map = new HashMap<>();
for (VarDef var : Act.viewManager().implicitActionViewVariables()) {
map.put(var.name(), var.type());
}
return map;
}
@Override
public void setRenderArgs(ITemplate iTemplate) {
// no need to set render args here as
// it's all done at TemplateBase#exposeImplicitVariables
}
});
RythmEngine engine = new RythmEngine(p);
engine.resourceManager().prependResourceLoader(new ClasspathResourceLoader(engine, ID));
if (config.defaultView() == this) {
String home = config.templateHome();
if (S.neq("default", home) && S.neq(ID, home)) {
engine.resourceManager().prependResourceLoader(new ClasspathResourceLoader(engine, home));
}
}
Tags tags = app.getInstance(Tags.class);
tags.register(engine);
return engine;
}
Aggregations