groupe-sii / ogham

Sending email, sms or whatever is a piece of cake
https://groupe-sii.github.io/ogham/
Apache License 2.0
21 stars 14 forks source link

Using fragments in a MultiContent template using Thymeleaf should not need the file extension #87

Open aurelien-baudet opened 4 years ago

aurelien-baudet commented 4 years ago

Path to a fragment from a template must currently contain '.html' or '.txt' whereas Thymeleaf documentation doesn't use file extension when referencing to a fragment.

So Ogham should follow the same behavior and resource resolution should use variants too to search for fragments.

Steps to Reproduce 1) Create a test that sends an email using a MultiTemplateContent:

   messagingService.send(new Email().content(new MultiTemplateContent("main.html")))...

2) Create a fragment fragment/layout.html:

   <head th:fragment="header">
    <meta charset="utf-8" />
    <link th:href="@{css/layout.css}" rel="stylesheet" type="text/css" />
    <link th:href="@{css/common.css}" rel="stylesheet" type="text/css" />
   </head>

3) Create a template that includes the fragment (main.html):

   <head th:replace="fragments/layout.html :: header"></head>

Current behavior:

Inclusion of fragment needs the file extension. <head th:replace="fragments/layout.html:: header"></head>

Expected behavior:

Inclusion of fragment should not need the file extension. <head th:replace="fragments/layout.html:: header"></head>

However, if file extension is explicitly provided, it should also work