-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for handlebar templates #93
base: master
Are you sure you want to change the base?
Conversation
Wow, that’s awesome, thank you. I won’t be able to look at it properly until next week, but I really appreciate you taking this on. I think I’d lean towards the second option since it’s closer to what you have to do in Jade and EJS, but I’ll keep thinking on that part. |
Yes, option 1 was defined in the initial tests you wrote, so I started with that syntax. The tough thing with handlebars is JS objects and arrays can not be defined inline to helpers, so if you notice the first two options are actually passing JSON. This can be awkward when you need to dynamically provide the locals. For example, trying to dynamically create a locals object from concatenation and stringify do not work: {{partial '../foo.jade' '{ "a":' + b + '" }' }}
{{partial '../foo.jade' JSON.stringify({ a: b }) }} I'd argue the 3rd option feels the cleanest to me, but also differs the most from ejs and jade: {{partial '../foo.jade' a=b }} However, options 2 & 3 can be combined with a subexpression. So, for example by adding an additional {{partial '../foo.jade' '{ "a": "b" }' }}
{{partial '../foo.jade' (locals a="b") }} This might give people the most flexibility, but still provide a similar API for defining locals amongst the various templating languages. |
Nice! I hope this works out. It would be awesome to see handlebars support land in terraform and harp. |
Per @mckramer’s suggestion #93 (comment)
+1 |
What status? Help is needed? |
Adding missing
partial
support from #36. See discussion in sintaxi/harp#246. I attempted to implement the tests that @kennethormandy provided.I'm not completely sold on the partial syntax, so would be interested in feedback. It is currently prepared as:
I did play with a few other syntaxes, such as passing an extra parameter:
And flattening the object as attributes: