groovy.text.GStringTemplateEngine Java Examples
The following examples show how to use
groovy.text.GStringTemplateEngine.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroovyDocTemplateEngine.java From groovy with Apache License 2.0 | 6 votes |
public GroovyDocTemplateEngine(GroovyDocTool tool, ResourceManager resourceManager, String[] docTemplates, String[] packageTemplates, String[] classTemplates, Properties properties) { this.resourceManager = resourceManager; this.properties = properties; this.docTemplatePaths = Arrays.asList(docTemplates); this.packageTemplatePaths = Arrays.asList(packageTemplates); this.classTemplatePaths = Arrays.asList(classTemplates); this.docTemplates = new LinkedHashMap<String, Template>(); this.packageTemplates = new LinkedHashMap<String, Template>(); this.classTemplates = new LinkedHashMap<String, Template>(); engine = new GStringTemplateEngine(); }
Example #2
Source File: AbstractDbDataLoader.java From yarg with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") protected String processQueryTemplate(String query, BandData parentBand, Map<String, Object> reportParams) { try { GStringTemplateEngine engine = new GStringTemplateEngine(); Map bindings = new HashMap(); if (reportParams != null) { bindings.putAll(reportParams); } while (parentBand != null) { if (parentBand.getData() != null) { bindings.put(parentBand.getName(), parentBand.getData()); } parentBand = parentBand.getParentBand(); } return engine.createTemplate(query).make(bindings).toString(); } catch (ClassNotFoundException | IOException e) { throw new DataLoadingException(String.format("An error occurred while loading processing query template [%s]", query), e); } }
Example #3
Source File: SuggestionFieldQueryLoader.java From cuba with Apache License 2.0 | 5 votes |
protected String applySearchFormat(String searchString, String format) { if (StringUtils.isNotEmpty(format)) { GStringTemplateEngine engine = new GStringTemplateEngine(); StringWriter writer = new StringWriter(); try { engine.createTemplate(format).make(ParamsMap.of("searchString", searchString)).writeTo(writer); return writer.toString(); } catch (ClassNotFoundException | IOException e) { throw new IllegalStateException(e); } } return searchString; }
Example #4
Source File: AbstractValidator.java From cuba with Apache License 2.0 | 5 votes |
/** * @param errorMessage error message * @param values values map * @return message with inserted values */ protected String getTemplateErrorMessage(String errorMessage, Map<String, Object> values) { if (!Strings.isNullOrEmpty(errorMessage)) { StringWriter writer = new StringWriter(); try { GStringTemplateEngine engine = new GStringTemplateEngine(); engine.createTemplate(errorMessage).make(values).writeTo(writer); return writer.toString(); } catch (ClassNotFoundException | IOException e) { throw new IllegalStateException(e); } } return errorMessage; }
Example #5
Source File: GroovyYamlTemplateProcessor.java From DotCi with MIT License | 5 votes |
public Map getConfig() { GStringTemplateEngine engine = new GStringTemplateEngine(); String yaml = null; try { yaml = engine.createTemplate(config).make(new MissingPropForwardingMap(envVars)).toString(); } catch (Exception e) { throw new RuntimeException(e); } return (Map) new Yaml().load(yaml); }
Example #6
Source File: HtmlFormatter.java From yarg with Apache License 2.0 | 5 votes |
protected groovy.text.Template getGroovyTemplate() { try { GStringTemplateEngine templateEngine = new GStringTemplateEngine(); String templateContent = IOUtils.toString(reportTemplate.getDocumentContent(), StandardCharsets.UTF_8); groovy.text.Template htmlTemplate = templateEngine.createTemplate(templateContent); return htmlTemplate; } catch (Exception e) { throw wrapWithReportingException("An error occurred while creating groovy template", e); } }
Example #7
Source File: GroovyGStringTemplateSupportImpl.java From yes-cart with Apache License 2.0 | 3 votes |
public GroovyGStringTemplateSupportImpl(final CacheManager cacheManager) throws ClassNotFoundException { TEMPLATE_CACHE = cacheManager.getCache("contentService-templateSupport"); final ClassLoader classLoader = this.getClass().getClassLoader(); classLoader.loadClass(DecimalFormat.class.getName()); this.engine = new GStringTemplateEngine(classLoader); }