Package com.github.jknack.handlebars

Examples of com.github.jknack.handlebars.Handlebars


            WebApp app = (WebApp) WebApp.getApp(request);
            Map<String, List<String>> context = new HashMap<String, List<String>>();
            context.put(PLUGIN_JS_RESOURCES_PARAM, app.getPluginsJsResources());
            context.put(PLUGIN_CSS_RESOURCES_PARAM, app.getPluginsCssResources());
            TemplateLoader templateLoader = new ServletContextTemplateLoader(request.getServletContext(), "/", ".hbs");
            Handlebars handlebars = new Handlebars(templateLoader);
            Template template = handlebars.compile("index");
            indexHtml = template.apply(context);
        }
        return indexHtml;
    }
View Full Code Here


            prefix = views;
        } else {
            prefix = views.endsWith("/") ? views : views + "/";
        }

        handlebars = new Handlebars(new TemplateLoader() {
            @Override
            public TemplateSource sourceAt(final String location) throws IOException {
                // load from the file system
                final String buffer = read(resolve(location));
View Full Code Here

  }

  @Provides
  @Singleton
  public Handlebars providesHandlebars() {
    final Handlebars handlebars = new Handlebars();

    handlebars.registerHelper(BashEscapedHelper.NAME, new BashEscapedHelper());
    handlebars.registerHelper(IfPresentHelper.NAME, new IfPresentHelper());

    return handlebars;
  }
View Full Code Here

  @SuppressWarnings("UnusedDeclaration")
  @Provides
  @Singleton
  Handlebars provideHandlebars(Injector injector, TemplateLoader templateLoader, TemplateCache templateCache) {

    final Handlebars handlebars = new Handlebars().with(templateLoader);
    handlebars.with(templateCache);
    GuiceUtil.eachOfType(injector, NAMED_HELPER_TYPE, helper -> handlebars.registerHelper(helper.getName(), helper));

    return handlebars;
  }
View Full Code Here

    private String classPathTemplatesBaseDir = "/views";

    @Override
    @JsonIgnore
    public Handlebars createInstance() {
        return new Handlebars().with(new ClassPathTemplateLoader(classPathTemplatesBaseDir, StringUtils.EMPTY));
    }
View Full Code Here

@JsonIgnoreProperties(ignoreUnknown = true, value = "type")
public abstract class HandlebarsConfig {

    @JsonIgnore
    public Handlebars getInstance(MetricRegistry metricRegistry) {
        Handlebars handlebars = createInstance();
        handlebars = setupTemplateCache(handlebars, metricRegistry);
        StringHelpers.register(handlebars);
        Base64StringHelpers.register(handlebars);
        return handlebars;
    }
View Full Code Here

    private String templateBaseDir;

    @Override
    @JsonIgnore
    public Handlebars createInstance() {
        return new Handlebars().with(new FileTemplateLoader(templateBaseDir, StringUtils.EMPTY));
    }
View Full Code Here

TOP

Related Classes of com.github.jknack.handlebars.Handlebars

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.