Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to use string template with JTE ? #405

Open
tangyk opened this issue Nov 22, 2024 · 2 comments
Open

How to use string template with JTE ? #405

tangyk opened this issue Nov 22, 2024 · 2 comments

Comments

@tangyk
Copy link

tangyk commented Nov 22, 2024

Hi,

I would like using string template with JTE.
Is there some example for doing this ?

For example:
String template = """
Hello, ${user}!
""";

are expected to be
Hello, Tom!
when parameter user is set to Tom.

Thank you for any help.

@rastegaev
Copy link

I have implemented StringCodeResolver(String template) implements CodeResolver.
But there is a problem that render creates only one file for many templates, idk what a reason for this

@casid
Copy link
Owner

casid commented Jan 3, 2025

I'm not sure what you would like to achieve. String templates where a preview feature that got remove from the latest Java version.

What you use in your example is a text block, but its behavior is identical to a String.

With Java 17 I changed most unit test input to text blocks because they read a lot better, like here:

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants