Integrating handlebars with an existing system

32 views
Skip to first unread message

Phil Waligora

unread,
May 9, 2017, 10:40:12 AM5/9/17
to handlebars.java
Hello,

I am working on a project for my company. We would like to support Handlebars syntax for a templating feature. We have an existing data structure on our side which acts as a Map for merge fields. This data structure handles our of our business rules for database access, user access, etc. We would very much like to re-use this logic with Handlebars.

What would be the best strategy for integrating? I see that the documents mention optionally using the MapValueResolver. So I have a few questions.

My initial thought is to write an adapter class which will translate our map into one that Handlebars can use.

Does it make more sense to define my own kind of ValueResolver, or would my adapter iterate through the values and add the required ones to the MapValueResolver?

Also, I am unclear how I would register the custom ValueResolver. I see this snippet of code in the documentation:

Context context = Context
.newBuilder(model)
.resolver(MapValueResolver.INSTANCE)
.build();

Where would this code be placed? Does this code override all existing resolvers in the system?

Thanks,
Phil
Reply all
Reply to author
Forward
0 new messages