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), reloaded #213

Merged
merged 1 commit into from Sep 1, 2015

Conversation

@decebals
Copy link
Member

@decebals decebals commented Sep 1, 2015

Implementation based on this comment.

I have a updated pippo-demo-template on pipe:

public class PebbleDemo {

    public static void main(String[] args) {
        // .peb is the default file extension
//        Pippo pippo = new Pippo(new TemplateApplication(new PebbleTemplateEngine(), "pebble/hello"));
        Pippo pippo = new Pippo(new TemplateApplication(new MyPebbleTemplateEngine(), "pebble/hello"));
        pippo.start();
    }

    public static class MyPebbleTemplateEngine extends PebbleTemplateEngine {

        @Override
        protected void init(PebbleEngine engine) {
            engine.addExtension(new AbstractExtension() {

                @Override
                public Map<String, Filter> getFilters() {
                    Map<String, Filter> filters = new HashMap<>();
                    filters.put("myupper", new MyUpperFilter());

                    return filters;
                }

            });
        }

    }

    public static class MyUpperFilter implements Filter {

        @Override
        public List<String> getArgumentNames() {
            return null;
        }

        @Override
        public Object apply(Object input, Map<String, Object> args){
            return (input != null) ? ((String) input).toUpperCase() : null;
        }

    }

}
gitblit added a commit that referenced this pull request Sep 1, 2015
make TemplateEngine configurable (see #211), reloaded
@gitblit gitblit merged commit f2f0f57 into master Sep 1, 2015
2 of 3 checks passed
2 of 3 checks passed
coverage/coveralls Coverage decreased (-0.02%) to 9.102%
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@gitblit
Copy link
Collaborator

@gitblit gitblit commented Sep 1, 2015

👍 Looks good.

@decebals decebals deleted the config_template_engine branch Sep 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.