handlebars.java icon indicating copy to clipboard operation
handlebars.java copied to clipboard

Scala Support

Open kevinwright opened this issue 6 years ago • 2 comments

I wrote a small adaptor allowing handlebars.java to be used with native Scala types (Scala collections and working with Scala reflection)

Gist here: https://gist.github.com/kevinwright/359329efcb166ec4f6ce59a228ee715f

Probably not a good idea to add to the core project because of the dependency it would introduce, but is this something you'd be interested in having as an "official" add-on module?

kevinwright avatar Jul 20 '18 08:07 kevinwright

Of course, will wait for pull request.

Thanks

jknack avatar Jul 23 '18 11:07 jknack

FWIW, we got around this by implementing a method that converts scala collections to java collections, and make sure to always use that when providing a model/context. Implementing a resolver for scala types like you're suggesting seems more elegant!

I'm a bit wary of the reflective resolver though; maybe create two new resolvers, one just for collections, and another that includes reflection?

dontgitit avatar Jul 24 '18 04:07 dontgitit