public TemplateNode() { ve = new VelocityEngine(); setProperties(); ve.init(); ve.loadDirective("org.onap.ccsdk.sli.plugins.template.HideNullJson"); }
private VelocityEngine newVelocityEngine(FitNesseContext context, String theme) { Properties properties = new Properties(); properties.setProperty(VelocityEngine.CHECK_EMPTY_OBJECTS, "false"); properties.setProperty(VelocityEngine.INPUT_ENCODING, FileUtil.CHARENCODING); properties.setProperty(VelocityEngine.RESOURCE_LOADER, "file,themepath,classpath"); properties.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, String.format("%s/files/fitnesse/templates", context.getRootPagePath())); properties.setProperty("themepath." + VelocityEngine.RESOURCE_LOADER + ".class", ClasspathResourceLoader.class.getName()); properties.setProperty("themepath." + VelocityEngine.RESOURCE_LOADER + ".base", String.format("/fitnesse/resources/%s/templates", theme)); properties.setProperty("classpath." + VelocityEngine.RESOURCE_LOADER + ".class", ClasspathResourceLoader.class.getName()); properties.setProperty("classpath." + VelocityEngine.RESOURCE_LOADER + ".base", "/fitnesse/resources/templates"); VelocityEngine engine = new VelocityEngine(); engine.init(properties); engine.loadDirective(TraverseDirective.class.getName()); engine.loadDirective(EscapeDirective.class.getName()); return engine; } }
engine.init(properties); engine.loadDirective(TraverseDirective.class.getName()); engine.loadDirective(EscapeDirective.class.getName()); return engine;
@Override public void initialize(Properties overridingProperties) throws XWikiVelocityException { org.apache.velocity.app.VelocityEngine velocityEngine = new org.apache.velocity.app.VelocityEngine(); // Add the Component Manager to allow Velocity extensions to lookup components. velocityEngine.setApplicationAttribute(ComponentManager.class.getName(), this.componentManager); // Set up properties initializeProperties(velocityEngine, this.velocityConfiguration.getProperties(), overridingProperties); // Set up directives velocityEngine.loadDirective(TryCatchDirective.class.getName()); try { velocityEngine.init(); } catch (Exception e) { throw new XWikiVelocityException("Cannot start the Velocity engine", e); } this.engine = velocityEngine; }