Closed wyaeld closed 11 months ago
Problem is, that the generate task does not have access to project classes yet.
You could change your build to use the precompile task, which has the property htmlPolicyClass
.
Since this is gradle, you could probably add a htmlPolicy
property to gg.jte.gradle.GenerateJteTask
. But then you would have to duplicate your policy class.
I split my Gradle projects into sub-projects. For example, JTE is in a 'views' sub-project, your policy could be in a 'shared' sub-project that 'views' depends on, and your server code in a 'server' sub-project that depends on both.
For the data that should be passed in to JTE template rendering, I put interfaces in the 'views' project and have model classes in the 'server' project implement them.
Checking things before I make changes, but looking here https://github.com/casid/jte/commit/ee6ae33707ba2315f3cce4ddf40ff1ad190a1478#diff-7c5716f58e03a18d258b4117d29790f25e14f0c2ddc98cb301b2ea144189e220R39
The JteExtension class already has place for HtmlPolicy, but we've tried it out - nothing happens - and looking through the code and the recent PR from @edward3h it doesn't appear to be connected up to the actual TemplateEngine, unless I'm missing some typical gradle indirection
I'm a bit slow, now that I've been digging into the code and docs together with your feedback I can see what's happening. Will keep trying to get this part to work and report back here
@casid you can close this issue, we have it working with precompile
. We did duplicate the policy class, as having the project gradle aware of the one buried in the application source code was a bit awkward for a few reasons, but that's a very minor tradeoff.
generate
ends up being no use to use. What is the intended use-case there?
This is related to https://github.com/casid/jte/pull/256
Runtime compiled templates are working fine.
However, we precompile templates for non-development environments using the gradle plugin, and even with both the library and plugin on version 3.0.3, this happens.
Looking at how the TemplateEngine is initiated here
https://github.com/casid/jte/blob/62159c17baabc89379992d08f8ca9a10b51dc013/jte-gradle-plugin/src/main/java/gg/jte/gradle/GenerateJteWorker.java#L26-L38
I don't see anything that allows for passing in our HotwirePolicy. Is there a way to do so that I'm not seeing. If not, could you support one?