updateTemplates()

in firestore-send-email/functions/lib/templates.js [47:91]


    updateTemplates(snap) {
        const all = snap.docs.map((doc) => Object.assign({ name: doc.id }, doc.data()));
        const partials = all.filter((t) => t.partial);
        const templates = all.filter((t) => !t.partial);
        partials.forEach((p) => {
            if (p.subject) {
                subjHandlebars.registerPartial(p.name, p.subject);
            }
            if (p.html) {
                htmlHandlebars.registerPartial(p.name, p.html);
            }
            if (p.text) {
                textHandlebars.registerPartial(p.name, p.text);
            }
            if (p.amp) {
                ampHandlebars.registerPartial(p.name, p.amp);
            }
            if (p.attachments) {
                logs_1.noPartialAttachmentSupport();
            }
            logs_1.registeredPartial(p.name);
        });
        templates.forEach((t) => {
            const tgroup = {};
            if (t.subject) {
                tgroup.subject = subjHandlebars.compile(t.subject, { noEscape: true });
            }
            if (t.html) {
                tgroup.html = htmlHandlebars.compile(t.html);
            }
            if (t.text) {
                tgroup.text = textHandlebars.compile(t.text, { noEscape: true });
            }
            if (t.amp) {
                tgroup.amp = ampHandlebars.compile(t.amp);
            }
            if (t.attachments) {
                tgroup.attachments = attachmentsHandlebars.compile(JSON.stringify(t.attachments), { strict: true });
            }
            this.templateMap[t.name] = tgroup;
            logs_1.templateLoaded(t.name);
        });
        this.ready = true;
        this.waits.forEach((wait) => wait());
    }