Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
robiasto opened this issue Jun 8, 2024 · 0 comments

Comments

@robiasto
Copy link

robiasto commented Jun 8, 2024

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;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant