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

How to configure Rocker to use GuavaHtmlStringify? #169

Open
franz1981 opened this issue Jun 22, 2023 · 4 comments
Open

How to configure Rocker to use GuavaHtmlStringify? #169

franz1981 opened this issue Jun 22, 2023 · 4 comments

Comments

@franz1981
Copy link

franz1981 commented Jun 22, 2023

I cannot find how to configure the template engine to use GuavaHtmlStringify instead of the default one for the DefaultRockerTemplate.__internal if not by manually allocating the view and override DefaultRockerTemplate buildTemplate() to create a custom one (manually crafted) like this

    private static final DefaultHtmlStringify STRINGIFY = new GuavaHtmlStringify();

    private static class CustomFortunesTemplate extends Fortunes.Template {

        public CustomFortunesTemplate(Fortunes model) {
            super(model);
            // super would set contentType HTML and force `DefaultHtmlStringify` :"(
            __internal.setStringify(STRINGIFY);
        }
    }
@jjlauer
Copy link
Member

jjlauer commented Jun 22, 2023

If gauva is on the classpath, I believe that becomes the default used.

@jjlauer jjlauer closed this as completed Nov 4, 2023
@franz1981
Copy link
Author

TBH by debugging it doesn't seem what's happening...

@jjlauer jjlauer reopened this Nov 4, 2023
@jjlauer
Copy link
Member

jjlauer commented Nov 4, 2023

Hmm.. it appears the Guava activation was commented out at some point. In RockerStringify:

static public final RockerStringify RAW = new RawStringify();
//static public final RockerStringify HTML = RockerRuntime.createDefaultHtmlStringify();
static public final RockerStringify HTML = new DefaultHtmlStringify();

The createDefaultHtmlStringify does activate Guava, otherwise the way it is now, it won't be. Not sure why this is commented out, but if you wanted to uncomment it, and try it locally out and let me know. Not sure if there was a good reason why this was commented out though at some point.

@jjlauer
Copy link
Member

jjlauer commented Nov 4, 2023

Actually, I just fixed a unit test that was failing if i re-activated it, and it seems to work well now. I pushed up to master fixing this guava issue. I'll run master thru a number of production tests though to make sure this wasn't significant.

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

2 participants