Whilst working through some notice bugs I noted that we now have a few different places where we wrap the content for output in various instants. I think we could centralise on the html_content method I introduce in bug 30287 and add support for the 'pre' (or perhaps replace pre with <div style="white-space: pre-wrap;"> as suggested in https://stackoverflow.com/questions/248011/how-do-i-wrap-text-in-a-pre-tag) for non html encoded templates. Thoughts?
Created attachment 158657 [details] [review] Bug 35285: Add non-html template support to html_content wrapping This patch adds support for messages generated using non-html formatted notice templates to the html_content method of Koha::Notice::Message. We continue to wrap content for html generated messages with the appropriate headers, css and title. For non-html generated content we wrap in the <div style="white-space: pre-wrap"> block to maintain text formatting as defined in the original plaintext template.
Work in progress
Created attachment 158658 [details] [review] Bug 35285: Remove switch in notices.tt We now wrap appropriately for non-html formatted messages as part of the html_content method. This means we can remove the case from members/notices.tt and rely on html_content doing the right thing for notice previews.
Created attachment 158889 [details] [review] Bug 35285: Add non-html template support to html_content wrapping This patch adds support for messages generated using non-html formatted notice templates to the html_content method of Koha::Notice::Message. We continue to wrap content for html generated messages with the appropriate headers, css and title. For non-html generated content we wrap in the <div style="white-space: pre-wrap"> block to maintain text formatting as defined in the original plaintext template. Test Follow the test plan for bug 30287, nothing should outwardly change.
Created attachment 158890 [details] [review] Bug 35285: Remove switch in notices.tt We now wrap appropriately for non-html formatted messages as part of the html_content method. This means we can remove the case from members/notices.tt and rely on html_content doing the right thing for notice previews.
Created attachment 158891 [details] [review] Bug 35285: Unit tests This patch adds unit tests for the new 'is_html' function introduced in Koha::Notice::Message and update the tests to include the new plaintext handling of html_content.
Created attachment 158960 [details] [review] Bug 35285: Add non-html template support to html_content wrapping This patch adds support for messages generated using non-html formatted notice templates to the html_content method of Koha::Notice::Message. We continue to wrap content for html generated messages with the appropriate headers, css and title. For non-html generated content we wrap in the <div style="white-space: pre-wrap"> block to maintain text formatting as defined in the original plaintext template. Test Follow the test plan for bug 30287, nothing should outwardly change. Signed-off-by: David Nind <david@davidnind.com>
Created attachment 158961 [details] [review] Bug 35285: Remove switch in notices.tt We now wrap appropriately for non-html formatted messages as part of the html_content method. This means we can remove the case from members/notices.tt and rely on html_content doing the right thing for notice previews. Signed-off-by: David Nind <david@davidnind.com>
Created attachment 158962 [details] [review] Bug 35285: Unit tests This patch adds unit tests for the new 'is_html' function introduced in Koha::Notice::Message and update the tests to include the new plaintext handling of html_content. Signed-off-by: David Nind <david@davidnind.com>