ultraq / thymeleafjs

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

Minimum set of processors needed to get it working for my needs :) #2

Closed ultraq closed 7 years ago

ultraq commented 7 years ago

After implementing the above, it's time to work on getting a proper architecture going to support it being super-configurable much like how Thymeleaf is. An example app would also be useful.

danielfernandez commented 7 years ago

Note that, even if you are implementing a very simplified version of the expression engine for now, you might want to take into account how Thymeleaf generally evaluates objects as boolean for th:if, th:unless (you can add it to your list, it will be almost free once you have th:if) and so.

For this, have a look at org.thymeleaf.util.EvaluationUtils#evaluateAsBoolean(...). And the EvaluationUtils class in general.

Also, another suggestion: IMHO for this to be useful from the beginning, th:each would be important. And this brings the topic of how to evaluate objects as iterables, for which you'd have to have a look at org.thymeleaf.engine.IteratedModelGatheredProcessable#computeIteratedObjectIterator(...)

ultraq commented 7 years ago

th:each is definitely useful - it just wasn't one of the tags I was using in my other project 😄

I think we need to come up with what a "minimum feature set" that we'll be happy with before we open this up to further experimentation.

Re: iterating an object and evaluating what is true/false - would we want to have the JS use the same semantics as the original Thymeleaf, or rather use the semantics that exist in the JS world already? eg: JS already has a concept of truthy/falsey, as well as what counts as iterable.