Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
builder.build = (filePath, outputDir, extension) => {
// No-op if filePath is not a file
if (!fs.statSync(filePath).isFile()) {
return;
}
const filename = getTemplateFilename(filePath).replace('.mjml', extension);
try {
const outputPath = path.join(process.cwd(), outputDir);
mkdir(outputPath);
const startTime = Date.now();
const data = fs.readFileSync(`${filePath}`, 'utf8');
const rendered = mjml2html(data);
fs.writeFileSync(`${outputPath}/${filename}`, rendered.html);
const endTime = Date.now();
const totalTime = endTime - startTime;
console.log(`Rendered ${filename} in ${totalTime}ms`); // eslint-disable-line
} catch (error) {
console.error(`Unable to render ${filename}`);
console.error(error.message);
}
};
const fs = require("fs");
const path = require("path");
const url = require("url");
const ejs = require("ejs");
const { mjml2html } = require('mjml'); // tslint:disable-line
const config_1 = require("../config");
const lodash_1 = require("lodash");
const BaseViewSet_1 = require("./BaseViewSet");
const ProjectInvite_1 = require("../models/ProjectInvite");
const ValidationError_1 = require("../errors/ValidationError");
const middleware_1 = require("../authentication/jwt/middleware");
const middleware_2 = require("../authorization/middleware");
const objection_1 = require("objection");
const validate_1 = require("../utils/validate");
const sendMail = config_1.default.MAIL_BACKEND.sendMail;
const projectInviteHTML = mjml2html(fs.readFileSync(path.resolve(__dirname, '../../templates/mail/project-invite.mjml'), 'utf8')).html;
const projectInviteTXT = fs.readFileSync(path.resolve(__dirname, '../../templates/mail/project-invite.txt'), 'utf8');
const createConstraints = {
name: {
presence: true,
length: {
maximum: 128
}
},
email: {
presence: true,
email: true
}
};
const acceptConstraints = {
token: {
presence: true
import url = require('url');
import * as ejs from 'ejs';
import { cloneDeep } from 'lodash';
const { mjml2html } = require('mjml'); // tslint:disable-line
import { transaction } from 'objection';
import User from '../models/User';
import Project from '../models/Project';
import ProjectInvite, { IInvitePayload } from '../models/ProjectInvite';
import BaseViewSet from './BaseViewSet';
import ValidationError from '../errors/ValidationError';
import NotFoundError from '../errors/NotFoundError';
import config from '../config';
import { requireAuthentication } from '../authentication/jwt/middleware';
import validate from '../utils/validate';
const signUpHTML = mjml2html(
fs.readFileSync(
path.resolve(__dirname, '../../templates/mail/sign-up-verify.mjml'), 'utf8'
)
).html;
const signUpTXT = fs.readFileSync(
path.resolve(__dirname, '../../templates/mail/sign-up-verify.txt'), 'utf8'
);
const requestPasswordResetHTML = mjml2html(
fs.readFileSync(
path.resolve(__dirname, '../../templates/mail/request-password-reset.mjml'), 'utf8'
)
).html;
const requestPasswordResetTXT = fs.readFileSync(
path.resolve(__dirname, '../../templates/mail/request-password-reset.txt'), 'utf8'
);
.then(function (response) {
emailTemplateHtml = response.data
processLog = _.chain(processLog).orderBy(['lastModified'], ['asc']).findLast((f) => { return f.jobId === job.data.jobId }).value()
for (var i = 0; i < runningProcess.inputProperty[0].entityschema.entity.length; i++) {
let element = runningProcess.inputProperty[0].entityschema.entity[i].name
// element = element.toLowerCase()
let index = emailTemplateHtml.search('"' + element + '"')
// element = _.capitalize(element)
emailTemplateHtml = emailTemplateHtml.substr(0, index + element.length + 3) + processLog.input[0][element] + emailTemplateHtml.substr(index + element.length + 3)
}
emailTemplateHtml = mjml2html(emailTemplateHtml)
})
.catch(function (error) {
import fs = require('fs');
import path = require('path');
import url = require('url');
import * as ejs from 'ejs';
const { mjml2html } = require('mjml'); // tslint:disable-line
import config from '../config';
import { cloneDeep } from 'lodash';
import BaseViewSet from './BaseViewSet';
import ProjectInvite from '../models/ProjectInvite';
import ValidationError from '../errors/ValidationError';
import { requireAuthentication } from '../authentication/jwt/middleware';
import { requirePermission } from '../authorization/middleware';
import { transaction } from 'objection';
import validate from '../utils/validate';
const projectInviteHTML = mjml2html(
fs.readFileSync(
path.resolve(__dirname, '../../templates/mail/project-invite.mjml'), 'utf8'
)
).html;
const projectInviteTXT = fs.readFileSync(
path.resolve(__dirname, '../../templates/mail/project-invite.txt'), 'utf8'
);
const createConstraints = {
name: {
presence: true,
length: {
maximum: 128
}
},
email: {
function handleAdjacentMJML(file, fileSystem, compiler, browserSync, event, mode) {
const content = customReadFile(file);
if (content.length) {
const { error, html } = mjml2html(content);
if (!error) {
handleAdjacentHTML(
file.replace(extname(file), '.html'),
html,
false,
fileSystem,
compiler,
browserSync,
event,
mode
);
} else {
console.log(error);
}
}
}
function resolver(rawTemplate) {
let { html } = mjml2html(rawTemplate, { filePath: template });
Object.keys(data).forEach((key) => {
const regex = new RegExp(`{${key}}`, 'g');
html = html.replace(regex, data[key]);
});
const mailOptions = {
from: sendmail.config.fromAddress,
html,
subject,
text,
to,
};
sendmail.config.transport.sendMail(mailOptions, (error) => {
if (error) {
let done = (source, isMjml = false) => {
if (isMjml) {
let compiled;
try {
compiled = mjml.mjml2html(source);
} catch (err) {
return callback(err);
}
if (compiled.errors.length) {
return callback(compiled.errors[0].message || compiled.errors[0]);
}
source = compiled.html;
}
let renderer = Handlebars.compile(source);
templates.set(key, renderer);
callback(null, renderer);
};
app.post('/mjml-render', (req, res) => {
const mjmlData = req.body.mjml;
const html = mjml2html(mjmlData);
res.json({
error: null,
html,
});
});
server.listen(PORT, ADDRESS, () => {