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

make TemplateEngine configurable (see #211) #212

Closed
wants to merge 1 commit into from

Conversation

decebals
Copy link
Member

A proof of concept. See #211 for more information.

Conclusion:

  • Groovy, we export MarkupTemplateEngine but my feeling is that we cannot modify some configuration parameters using this object
  • Jade, we export JadeConfiguration, not the engine
  • Pebble, we export PebbleEngine, perfect
  • Trimou, we export MustacheEngine but all settings are done in a previous step in MustacheEngineBuilder, my feeling is that we cannot modify some configuration parameters using this object (MustacheEngine)
  • Freemarker, we export Configuration, not the engine
  • Velocity, we export Velocity engine but all settings are done in a previous step

So, I don't have a perfect fit. I will try to dig more. Any idea is welcome.

@gitblit
Copy link
Collaborator

gitblit commented Aug 31, 2015

A perfect fit looks to be difficult.

Maybe a better alternative would be to make it easier to subclass a TemplateEngine and then manually assign it rather than trying to tweak whatever is discovered?

public class TrimouTemplateEngine {
    @Override
    public void init(Applicaiton application) {
        // normal init stuff...

        // allow custom initialization
        init(builder);

        // create final engine
        engine = builder.build();
    }

    protected void init(MustacheEngineBuilder builder) {
    }
}

public class MyMoustache extends TrimouTemplateEngine {
    @Override
    protected void init(MustacheEngineBuilder builder) {
        builder.registerHelper("trimmer", new MyMoustacheTrimmer());
    }
}

With this we would do:

Application.get().setTemplateEngine(new MyMoustacheEngine());

@decebals
Copy link
Member Author

Good idea. I will try your approach.

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

Successfully merging this pull request may close these issues.

2 participants