Package com.github.jknack.handlebars.springmvc

Examples of com.github.jknack.handlebars.springmvc.HandlebarsViewResolver


        List<Object> helperSources = new ArrayList<Object>();
        HelperSourceMock helperSourceMock = new HelperSourceMock();
        helperSources.add(helperSourceMock);
        postProcessor.setHelperSources(helperSources);

        HandlebarsViewResolver viewResolver = EasyMock.createMock(HandlebarsViewResolver.class);

        Object otherBean = EasyMock.createMock(Object.class);

        reset(viewResolver, otherBean);

        expect(viewResolver.registerHelper("foo", helperMock)).andReturn(viewResolver).once();
        expect(viewResolver.registerHelpers(helperSourceMock)).andReturn(viewResolver).once();

        replay(viewResolver, otherBean);

        postProcessor.postProcessBeforeInitialization(viewResolver, "handlebarsViewResolver");
        postProcessor.postProcessBeforeInitialization(otherBean, "otherBean");
View Full Code Here


   * @return A new {@link HandlebarsViewResolver}.
   */
  @Bean
  public HandlebarsViewResolver viewResolver(final Mode mode) {
    notNull(mode, "The mode is required.");
    final HandlebarsViewResolver viewResolver = new HandlebarsViewResolver();
    viewResolver.registerHelper("@json", Jackson2Helper.INSTANCE);
    viewResolver.setCache(!mode.isDev());
    viewResolver.setSuffix(".html");

    return viewResolver;
  }
View Full Code Here

     * Set helpers and helperSources on handlebars view resolver bean.
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("handlebarsViewResolver") && bean instanceof HandlebarsViewResolver) {
            HandlebarsViewResolver viewResolver = ((HandlebarsViewResolver)bean);

            for (Map.Entry<String, Helper<?>> helperEntry : helpers.entrySet()) {
                viewResolver.registerHelper(helperEntry.getKey(), helperEntry.getValue());
            }

            for (Object helperSource : helperSources) {
                viewResolver.registerHelpers(helperSource);
            }
        }

        return bean;
    }
View Full Code Here

TOP

Related Classes of com.github.jknack.handlebars.springmvc.HandlebarsViewResolver

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.