ultraq / thymeleafjs

A basic implementation of the Thymeleaf templating engine in JavaScript
Apache License 2.0
52 stars 8 forks source link

Add support for accessing values by array index #44

Closed poly-glot closed 3 years ago

poly-glot commented 3 years ago

Added indexed access to arrays or collections with brackets and without quotes.

ultraq commented 3 years ago

Hey there, thanks for the PR! My biggest concern with it is having to lean on lodash.get for this functionality as I feel it's a bit excessive: that package is 4.4KB in size, a quarter of the entirety of thymeleafjs!

However, I do like the tests and the placement of the new rule such that it works with the rest of the expression language.

If you have any ideas for implementing the functionality in a lightweight manner, then I'd be open to that. If after a while nothing comes up, then I may merge this PR anyway and figure out something that still manages to pass those tests before a next release since I do really like those other bits 🙂

poly-glot commented 3 years ago

Hi @ultraq

Thanks for your feedback. It is a fair point. I will see if I can find a suitable lightweight solution.

Regards Junaid

poly-glot commented 3 years ago

Hi @ultraq

Reported lodash dependency has been removed.

Thanks Junaid