JteModels extension with a 'Plain' (non-HTML engine)
In following the JteModels documentation I seem to be able to only create Html based templates.
However, I need to create a few text (plain) templates.
Does that support exist? Any hint on how that might be configured?
I'll be happy to provide a PR for the docs once I figure out what is missing...
Hi @checketts, I'm the author of jte-models. I'm kinda busy but I will try to get back to you at the weekend.
Thanks for the jte-models!
Here is my imagined way of making it work:
//Generate HTML based templates
jteExtension("gg.jte.models.generator.ModelExtension") {
property("language", "Kotlin")
property("excludePattern", ".*_text.*")
}
//Generate Text based templates
jteExtension("gg.jte.models.generator.ModelExtension") {
property("language", "Kotlin")
property("package", "gg.jte.generated.precompiled.text") // Will place the `Templates` classes in this package
property("contentType", "plain")
property("includePattern", ".*_text.*")
}
Note the new package and contentType options.
jte-models can generate models for plain text templates. It uses the contentType specified on the jte { } block in Gradle.
This does make it difficult to use both HTML and plain templates at the same time. I think you would have to put them in separate submodules.
Sorry for the delay in responding, by the way.
It would not be too hard to make your imagined configuration work, but it would require some code changes.
Thanks for the response. My usecase is generating emails, since email has an HTML envelope and a plaintext. So separate modules wouldn't necessarily work for me.
Are you aware of a way to pass separate jteExtension config to a separate Gradle task? Perhaps I could investigate that route.
The JTE Gradle plugin currently makes some assumptions that will prevent you configuring a separate task with different settings. It would be good to fix, but I don't have time available to work on that at the moment.
doc for jte-models https://jte.gg/jte-models/ is un clear, and not working with maven, no StaticTemplates is generated
- when switching to
generate-sourcesmaven compile errorcannot find symbol - package gg.jte.models.runtime does not exist even if I add dependency jte-runtime
@sysmat This test case in JTE, uses jte-models with Maven. Can you look at that as an example?
(I'm a Gradle user: my Maven knowledge is limited.)
https://github.com/casid/jte/pull/450 is related in a minor way - allows naming the templates interface.
- @edward3h the problem is in documentation, where dependency is only in plugin, but it must be also in top level dependencies
- correct pom.xm
<dependencies>
<dependency>
<groupId>gg.jte</groupId>
<artifactId>jte</artifactId>
<version>${jte.version}</version>
</dependency>
<!-- MUST BE ALSO HERE -->
<dependency>
<groupId>gg.jte</groupId>
<artifactId>jte-models</artifactId>
<version>${jte.version}</version>
</dependency>
.....
</dependencies>
<build>
<plugins>
<plugin>
<groupId>gg.jte</groupId>
<artifactId>jte-maven-plugin</artifactId>
<version>${jte.version}</version>
<configuration>
<sourceDirectory>${project.basedir}/src/main/resources/jte</sourceDirectory>
<contentType>Plain</contentType>
<extensions>
<extension>
<className>gg.jte.models.generator.ModelExtension</className>
</extension>
</extensions>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<!-- NOT enough just here -->
<dependency>
<groupId>gg.jte</groupId>
<artifactId>jte-models</artifactId>
<version>${jte.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
@sysmat thanks, that makes sense. Can you make a PR to fix the documentation?