thymeleaf-tests icon indicating copy to clipboard operation
thymeleaf-tests copied to clipboard

Added inputStream method to ITemplateResources

Open ebolwidt-atlassian opened this issue 6 years ago • 0 comments

The main reason for adding this is our usecase of using thymeleaf for e-mail templates.

To refer to images and other binary resources, I created an extension tag processor that reads the resource, adds it to a special container in a context, and outputs a "cid:unique-code" url to refer to the image. However I need to be able to load the resource as binary data, and ITemplateResource only has a reader method. I added an inputStream method to ITemplateResource and all its implementations in the thymeleaf and thymeleaf-spring repositories. I added a unit test so that this method has the same amount of testing as the reader method.

(Since the reader methods were all changes to use the inputStream method to avoid code duplication, the ability to load a resource at all also means that the inputStream() method worked, so it's implicitly tested in many more cases, just as the reader method is)

This pull request has accompanying pull requests in thymeleaf-spring and thymeleaf repositories.

ebolwidt-atlassian avatar Oct 30 '18 05:10 ebolwidt-atlassian