use of groovy.text.TemplateEngine in project airavata by apache.
the class GFacUtils method generateScript.
public static String generateScript(GroovyMap groovyMap, String templateName) throws GFacException {
URL templateUrl = ApplicationSettings.loadFile(templateName);
if (templateUrl == null) {
String error = "Template file '" + templateName + "' not found";
throw new GFacException(error);
}
File template = new File(templateUrl.getPath());
TemplateEngine engine = new GStringTemplateEngine();
Writable make;
try {
make = engine.createTemplate(template).make(groovyMap);
} catch (Exception e) {
throw new GFacException("Error while generating script using groovy map", e);
}
return make.toString();
}
use of groovy.text.TemplateEngine in project spring-framework by spring-projects.
the class GroovyMarkupConfigurerTests method customTemplateEngine.
@Test
public void customTemplateEngine() throws Exception {
this.configurer.setApplicationContext(this.applicationContext);
this.configurer.setTemplateEngine(new TestTemplateEngine());
this.configurer.afterPropertiesSet();
TemplateEngine engine = this.configurer.getTemplateEngine();
assertThat(engine).isNotNull();
assertThat(engine.getClass()).isEqualTo(TestTemplateEngine.class);
}
use of groovy.text.TemplateEngine in project spring-framework by spring-projects.
the class GroovyMarkupViewTests method detectTemplateEngine.
@Test
public void detectTemplateEngine() throws Exception {
GroovyMarkupView view = new GroovyMarkupView();
view.setTemplateEngine(new TestTemplateEngine());
view.setApplicationContext(this.webAppContext);
DirectFieldAccessor accessor = new DirectFieldAccessor(view);
TemplateEngine engine = (TemplateEngine) accessor.getPropertyValue("engine");
assertThat(engine).isNotNull();
assertThat(engine.getClass()).isEqualTo(TestTemplateEngine.class);
}
use of groovy.text.TemplateEngine in project spring-framework by spring-projects.
the class GroovyMarkupConfigurerTests method customTemplateConfiguration.
@Test
public void customTemplateConfiguration() throws Exception {
this.configurer.setApplicationContext(this.applicationContext);
this.configurer.setCacheTemplates(false);
this.configurer.afterPropertiesSet();
TemplateEngine engine = this.configurer.getTemplateEngine();
assertThat(engine).isNotNull();
assertThat(engine.getClass()).isEqualTo(MarkupTemplateEngine.class);
MarkupTemplateEngine markupEngine = (MarkupTemplateEngine) engine;
TemplateConfiguration configuration = markupEngine.getTemplateConfiguration();
assertThat(configuration).isNotNull();
assertThat(configuration.isCacheTemplates()).isFalse();
}
use of groovy.text.TemplateEngine in project spring-framework by spring-projects.
the class GroovyMarkupConfigurerTests method defaultTemplateEngine.
@Test
public void defaultTemplateEngine() throws Exception {
this.configurer.setApplicationContext(this.applicationContext);
this.configurer.afterPropertiesSet();
TemplateEngine engine = this.configurer.getTemplateEngine();
assertThat(engine).isNotNull();
assertThat(engine.getClass()).isEqualTo(MarkupTemplateEngine.class);
MarkupTemplateEngine markupEngine = (MarkupTemplateEngine) engine;
TemplateConfiguration configuration = markupEngine.getTemplateConfiguration();
assertThat(configuration).isNotNull();
assertThat(configuration.getClass()).isEqualTo(GroovyMarkupConfigurer.class);
}
Aggregations