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

[Thymeleaf] Support the additional Dialects #70

Open
yoshikawaa opened this issue Mar 11, 2018 · 0 comments
Open

[Thymeleaf] Support the additional Dialects #70

yoshikawaa opened this issue Mar 11, 2018 · 0 comments

Comments

@yoshikawaa
Copy link

Problem

If we want to use our own Thymeleaf dialect with spark-template-thymeleaf, there is no point we can add them... I think it would be nice to be able to add dialects in the ThymeleafTemplateEngine.

Coding Point

Way 1 : adding constructor and initialize method
    public ThymeleafTemplateEngine(IDialect... additionalDialects) {
        this(DEFAULT_PREFIX, DEFAULT_SUFFIX, additionalDialects);
    }

    public ThymeleafTemplateEngine(String prefix, String suffix, IDialect... additionalDialects) {
        initialize(createDefaultTemplateResolver(prefix, suffix), additionalDialects);
    }

    public ThymeleafTemplateEngine(ITemplateResolver templateResolver, IDialect... additionalDialects) {
        initialize(templateResolver, additionalDialects);
    }

    private void initialize(ITemplateResolver templateResolver, IDialect... additionalDialects) {
        templateEngine = new org.thymeleaf.TemplateEngine();
        templateEngine.setTemplateResolver(templateResolver);
        templateEngine.addDialect(new Java8TimeDialect());
        if (additionalDialects != null && additionalDialects.length > 0) {
            templateEngine.setAdditionalDialects(new HashSet<>(Arrays.asList(additionalDialects)));
        }
    }
Way 2 : chahge accessibility of the templateEngine field and initialize method to protected

The user extends and uses this.


Please consider according to your implementation policy, thanks.

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