Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Does layout dialect work with TemplateMode.TEXT? #226

Open
GGuedesAB opened this issue Sep 6, 2022 · 2 comments
Open

Does layout dialect work with TemplateMode.TEXT? #226

GGuedesAB opened this issue Sep 6, 2022 · 2 comments
Assignees
Labels

Comments

@GGuedesAB
Copy link

GGuedesAB commented Sep 6, 2022

When I request a template to be processed, it does not decorate the template it should decorate.
Am I missing something? I read https://ultraq.github.io/thymeleaf-layout-dialect/ and https://www.thymeleaf.org/doc/articles/layouts.html and could not find any information about the support of TemplateMode.TEXT.

Here is my testcase:

Thymeleaf v3.0.15
thymeleaf-layout-dialect v3.1.0
JDK v1.8.0_65:

layout.txt:

List of contents:
[# layout:fragment="list" /]

contents.txt:

[# layout:decorate="~{layout}"]
[# layout:fragment="list"]
[# th:each="element: ${myList}"][[${element}]], [/]
[/]
[/]

TemplateGen.java:

public class TemplateGen {
    public static void main(String[] args) {
        FileTemplateResolver templateResolver = new FileTemplateResolver();
        templateResolver.setTemplateMode(TemplateMode.TEXT);
        templateResolver.setPrefix("templates/");
        templateResolver.setSuffix(".txt");
        final TemplateEngine templateEngine = new TemplateEngine();
        templateEngine.setTemplateResolver(templateResolver);
        templateEngine.addDialect(new LayoutDialect(null, false));

        List<String> myList = Arrays.asList("Pepper", "Milk", "Tea");
        final Context ctx = new Context();
        ctx.setVariable("myList", myList);
        Writer output = new OutputStreamWriter(System.out);
        templateEngine.process("contents", ctx, output);
    }
}

Output:



Pepper, Milk, Tea, 

@ultraq
Copy link
Owner

ultraq commented Sep 7, 2022

Unfortunately the layout dialect does not support the TEXT template mode, only HTML and XML. It could be something to add - I think you're the first to ever ask about it!

@ultraq ultraq added the question label Sep 7, 2022
@ultraq ultraq self-assigned this Sep 7, 2022
@JapuDCret
Copy link

Would also be interested in this

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

No branches or pull requests

3 participants