CerberusMVC Documentation

Template


This area is designated for template responses. For example, you could build email responses ehre that you include, passing on to the comms Library class.

Example Email Template

Using property injection for passing data into the template.

'use strict';

const DataTools = require('cerberus-mvc/Library/DataTools');

/**
 * @namespace API/View/Email
 * @class ContactFormHtml
 * @description Admin based email to ask them to activate a new verified user
 * @author Paul Smith (ulsmith)  
 * @copyright 2020 Paul Smith (ulsmith) all rights reserved
 * @license MIT 
 */
const ContactFormHtml = (props) => DataTools.html`
	

	

NO REPLY!

Use Link Below to Reply

Hi

We have had a new message on something.net from ${props.email}, the message is contained below.

name: ${props.name}

email: ${props.email}



${props.message}


To reply to this message CLICK HERE

`; /** * @namespace API/View/Email * @class ContactFormText * @description Admin based email to ask them to activate a new verified user * @author Paul Smith (ulsmith) * @copyright 2020 Paul Smith (ulsmith) all rights reserved * @license MIT */ const ContactFormText = (props) => DataTools.text` NO REPLY Do not reply to this message, use a new email to the recipient below. Hi We have had a new message on something.net from ${props.email}, the message is contained below. ${props.name} ${props.email} -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ${props.message} -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- `; module.exports = { ContactFormHtml, ContactFormText };

You would then be able to use the templates as so...


let emailData = { name: 'Me', email: '...', message: '...' }
let template = ContactFormHtml(emailData);
// template is now html content with properties spliced in!
// pass thi sto the comms library to send it as email content