Skip to content

Possible Bug(fix) of extending Thymleaf sayhelloextendingthymeleaf5minutes.md #98

@robiasto

Description

@robiasto

Actual example found here does not work for me.

@Bean
public SpringTemplateEngine templateEngine(){
    SpringTemplateEngine templateEngine = new SpringTemplateEngine();
    templateEngine.setEnableSpringELCompiler(true);
    templateEngine.setTemplateResolver(templateResolver());
    templateEngine.addDialect(new HelloDialect());

    return templateEngine;
}

Problems:

  1. templateResolver() not implemented.
  2. Other dialects like for exanple "thymeleaf-layout-dialect" don't work any more.

My Fix

@Bean
    public SpringTemplateEngine templateEngine(ClassLoaderTemplateResolver templateResolver,  ObjectProvider<IDialect> dialects){
        SpringTemplateEngine templateEngine  = new SpringTemplateEngine();
        templateEngine.setEnableSpringELCompiler(true);
        templateEngine.setTemplateResolver(templateResolver);
        dialects.orderedStream().forEach(templateEngine::addDialect);
        templateEngine.addDialect(new HelloDialect());

        return templateEngine;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions