mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 00:20:45 +00:00
Add nl2br Handlebars helper and use in template
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled
Convert newline characters in email reason text to <br /> tags and ensure proper escaping. Replaced {{reason}} with {{{nl2br reason}}} in the rejection template and registered an nl2br Handlebars helper that escapes HTML entities, transforms newlines to <br /> and returns a SafeString so line breaks render correctly in emails.
This commit is contained in:
@@ -50,9 +50,9 @@ The Puter Team
|
||||
html: `
|
||||
<p>Hi{{#if owner_username}} {{owner_username}}{{/if}},</p>
|
||||
<p>
|
||||
Thanks for submitting <a href="https://puter.com/app/{{app_name}}">{{app_title}}</a> for the Puter App Center. We reviewed your listing and have rejected it for the following reason:
|
||||
Thanks for submitting <a href="https://puter.com/app/{{app_name}}">{{app_title}}</a> for the Puter App Center. We reviewed your listing and have rejected it for the following reason(s):
|
||||
</p>
|
||||
<blockquote>{{reason}}</blockquote>
|
||||
<blockquote>{{{nl2br reason}}}</blockquote>
|
||||
<p>
|
||||
Please update your app listing and resubmit when ready. If you have questions, just reply to this email.
|
||||
</p>
|
||||
@@ -219,6 +219,17 @@ class Emailservice extends BaseService {
|
||||
_construct () {
|
||||
this.templates = TEMPLATES;
|
||||
|
||||
const handlebars = this.modules.handlebars;
|
||||
handlebars.registerHelper('nl2br', (text) => {
|
||||
if ( text == null ) return '';
|
||||
const s = String(text)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
return new handlebars.SafeString(s.replace(/\n/g, '<br />'));
|
||||
});
|
||||
|
||||
this.template_fns = {};
|
||||
for ( const k in this.templates ) {
|
||||
const template = this.templates[k];
|
||||
|
||||
Reference in New Issue
Block a user