jknack / handlebars.java

Logic-less and semantic Mustache templates with Java
http://jknack.github.io/handlebars.java
Other
1.48k stars 383 forks source link

support passing hash to partials #357

Closed mattkime closed 9 years ago

mattkime commented 9 years ago

see https://github.com/wycats/handlebars.js/pull/182

support {{> partialName hashKey="foo"}}

(correct me if i'm wrong, but i attempted to use this feature and got an error so i assume its not supported. this is new in handlebars.js 2.0)

jfbrennan commented 9 years ago

Same problem here, but two things to note:

1) if your NOT using Spring MVC, i.e. you're using Handlebars directly, then you need to do: new Handlebars( ).withJsFile("handlebars-2.0")

This is because Handlebars.java 2.0 actually defaults to using handlebars.js 1.3 (which seems crazy to me)

2) if you are using Spring like me, then you're totally out of luck for now because the HandlebarsViewResolver just takes the default (1.3) and there's no way to override that. Totally lame and I came here to submit an issue for that.

From what I can tell, Handlebars.java 2.0 is for all intents and purposes still just Handlebars 1.3.

Someone please tell me I'm missing something...

jfbrennan commented 9 years ago

@jknack this is a duplicate of issue #350

jknack commented 9 years ago

Guys,

I will try to find some time and do these changes. I've been busy working on my new project: jooby

But also, handlebarsjs 1.x has been around for years! and now in just a few month there is a 2.x and 3.x versions :S I'm not saying that is wrong but it is hard to keep track of everything. So, I decided to collect new feature request/bugs from handlebars.java users and after that, do the necessarily changes.

The reason of keep using handlebars 1.3 in handlebars 2.0 was backward compatibility, but I think I will change this in next release.

@jfbrennan always forgot to update the Spring module :S but you are not lost. There is a workaround:

HandlebarsViewResolver viewResolver = new HandlebarsViewResolver() {
      @Override
      protected Handlebars createHandlebars(URLTemplateLoader templateLoader) {
        Handlebars hbs = super.createHandlebars(templateLoader);
        hbs.withJsFile("...");
        return hbs;
      }
    };

Thanks

jfbrennan commented 9 years ago

Ah, duh! Thanks man

jfbrennan commented 9 years ago

@mattkime nevermind, I think you already understand what I'm just learning which is that handlebarsJsFile is only used for the precompile helper/maven plugin.

jknack commented 9 years ago

duplicate of #350