Search in sources :

Example 1 with SpacelessExtension

use of org.jtwig.spaceless.SpacelessExtension in project sakuli by ConSol.

the class AbstractTemplateOutputBuilder method createOutput.

/**
     * Converts the current test suite to a string based on the template for the concrete converter.
     *
     * @return
     */
public String createOutput() throws SakuliForwarderException {
    try {
        JtwigModel model = createModel();
        EnvironmentConfiguration configuration = EnvironmentConfigurationBuilder.configuration().extensions().add(new SpacelessExtension(new SpacelessConfiguration(new LeadingWhitespaceRemover()))).and().functions().add(new IsBlankFunction()).add(new GetOutputStateFunction()).add(new GetOutputDurationFunction()).add(new ExtractScreenshotFunction(screenshotDivConverter)).add(new AbbreviateFunction()).and().build();
        JtwigTemplate template = JtwigTemplate.fileTemplate(getTemplatePath().toFile(), configuration);
        logger.debug(String.format("Render model into JTwig template. Model: '%s'", model));
        return template.render(model);
    } catch (Throwable thr) {
        throw new SakuliForwarderException(thr, "Exception during rendering of Twig template occurred!");
    }
}
Also used : SpacelessExtension(org.jtwig.spaceless.SpacelessExtension) SakuliForwarderException(org.sakuli.exceptions.SakuliForwarderException) JtwigTemplate(org.jtwig.JtwigTemplate) SpacelessConfiguration(org.jtwig.spaceless.configuration.SpacelessConfiguration) JtwigModel(org.jtwig.JtwigModel) EnvironmentConfiguration(org.jtwig.environment.EnvironmentConfiguration)

Example 2 with SpacelessExtension

use of org.jtwig.spaceless.SpacelessExtension in project sakuli by ConSol.

the class AbstractTemplateOutputBuilder method createOutput.

/**
 * Converts the current test data entity to a string based on the template for the concrete converter.
 *
 * @param abstractTestDataEntity Test data entity, which has to be converted
 * @return A string representation of the provided test data entity
 */
public String createOutput(AbstractTestDataEntity abstractTestDataEntity) throws SakuliForwarderCheckedException {
    try {
        JtwigModel model = createModel(abstractTestDataEntity);
        EnvironmentConfiguration configuration = EnvironmentConfigurationBuilder.configuration().extensions().add(new SpacelessExtension(new SpacelessConfiguration(new LeadingWhitespaceRemover()))).and().functions().add(new IsBlankFunction()).add(new GetOutputStateFunction()).add(new GetOutputDurationFunction()).add(new ExtractScreenshotFunction(screenshotDivConverter)).add(new AbbreviateFunction()).add(new UnixTimestampConverterFunction()).add(new GetTestDataEntityTypeFunction()).and().build();
        JtwigTemplate template = JtwigTemplate.fileTemplate(getTemplatePath().toFile(), configuration);
        logger.debug(String.format("Render model into JTwig template. Model: '%s'", model));
        return template.render(model);
    } catch (Exception e) {
        throw new SakuliForwarderCheckedException(e, "Exception during rendering of Twig template occurred!");
    }
}
Also used : SpacelessExtension(org.jtwig.spaceless.SpacelessExtension) JtwigTemplate(org.jtwig.JtwigTemplate) FileNotFoundException(java.io.FileNotFoundException) SakuliForwarderCheckedException(org.sakuli.exceptions.SakuliForwarderCheckedException) SpacelessConfiguration(org.jtwig.spaceless.configuration.SpacelessConfiguration) JtwigModel(org.jtwig.JtwigModel) EnvironmentConfiguration(org.jtwig.environment.EnvironmentConfiguration) SakuliForwarderCheckedException(org.sakuli.exceptions.SakuliForwarderCheckedException)

Aggregations

JtwigModel (org.jtwig.JtwigModel)2 JtwigTemplate (org.jtwig.JtwigTemplate)2 EnvironmentConfiguration (org.jtwig.environment.EnvironmentConfiguration)2 SpacelessExtension (org.jtwig.spaceless.SpacelessExtension)2 SpacelessConfiguration (org.jtwig.spaceless.configuration.SpacelessConfiguration)2 FileNotFoundException (java.io.FileNotFoundException)1 SakuliForwarderCheckedException (org.sakuli.exceptions.SakuliForwarderCheckedException)1 SakuliForwarderException (org.sakuli.exceptions.SakuliForwarderException)1