001package io.jstach.opt.dropwizard;
002
003import io.dropwizard.views.common.View;
004import io.jstach.jstachio.Template;
005
006/**
007 * A mixin for generated templates to create dropwizard views.
008 *
009 * @author agentgt
010 * @param <T> model type
011 */
012public interface ViewableTemplate<T> extends Template<T> {
013
014        /**
015         * Creates a dropwizard view from the model and this template. JStachio will not need
016         * to lookup the template that corresponds to the model.
017         * @param model model that the template can render
018         * @return dropwizard view
019         */
020        @SuppressWarnings("exports")
021        default View view(T model) {
022                return JStachioView.of(model(model));
023        }
024
025}