mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Changed {subscriber_firstname} replacement to {first_name}
no issue - easier to remember and type - removes need to remove the `subscriber_` prefix when accessing member properties
This commit is contained in:
parent
944ffa8668
commit
9981ea336c
3 changed files with 5 additions and 5 deletions
|
@ -26,9 +26,9 @@ const getEmailData = async (postModel, members = []) => {
|
|||
members.forEach((member) => {
|
||||
emails.push(member.email);
|
||||
|
||||
// firstname is a computed property only used here for now
|
||||
// first_name is a computed property only used here for now
|
||||
// TODO: move into model computed property or output serializer?
|
||||
member.firstname = (member.name || '').split(' ')[0];
|
||||
member.first_name = (member.name || '').split(' ')[0];
|
||||
|
||||
// add static data to mailgun template variables
|
||||
const data = {
|
||||
|
|
|
@ -60,7 +60,7 @@ const _parseReplacements = (emailTmpl) => {
|
|||
const EMAIL_REPLACEMENT_REGEX = /%%(\{.*?\})%%/g;
|
||||
// the " is necessary here because `juice` will convert "->" for email compatibility
|
||||
const REPLACEMENT_STRING_REGEX = /\{(?<memberProp>\w*?)(?:,? *(?:"|")(?<fallback>.*?)(?:"|"))?\}/;
|
||||
const ALLOWED_REPLACEMENTS = ['subscriber_firstname'];
|
||||
const ALLOWED_REPLACEMENTS = ['first_name'];
|
||||
|
||||
const replacements = [];
|
||||
['html', 'plaintext'].forEach((format) => {
|
||||
|
@ -77,7 +77,7 @@ const _parseReplacements = (emailTmpl) => {
|
|||
format,
|
||||
id,
|
||||
match: replacementMatch,
|
||||
memberProp: memberProp.replace('subscriber_', ''),
|
||||
memberProp,
|
||||
fallback
|
||||
});
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ describe('Email Preview API', function () {
|
|||
id: ObjectId.generate(),
|
||||
title: 'Post with email-only card',
|
||||
slug: 'email-only-card',
|
||||
mobiledoc: '{"version":"0.3.1","atoms":[],"cards":[["email",{"html":"<p>Hey {subscriber_firstname \\"there\\"} {unknown}</p><p><strong>Welcome to your first Ghost email!</strong></p>"}],["email",{"html":"<p>Another email card with a similar replacement, {subscriber_firstname, \\"see?\\"}</p>"}]],"markups":[],"sections":[[10,0],[1,"p",[[0,[],0,"This is the actual post content..."]]],[10,1],[1,"p",[]]]}',
|
||||
mobiledoc: '{"version":"0.3.1","atoms":[],"cards":[["email",{"html":"<p>Hey {first_name \\"there\\"} {unknown}</p><p><strong>Welcome to your first Ghost email!</strong></p>"}],["email",{"html":"<p>Another email card with a similar replacement, {first_name, \\"see?\\"}</p>"}]],"markups":[],"sections":[[10,0],[1,"p",[[0,[],0,"This is the actual post content..."]]],[10,1],[1,"p",[]]]}',
|
||||
html: '<p>This is the actual post content...</p>',
|
||||
plaintext: 'This is the actual post content...',
|
||||
status: 'draft',
|
||||
|
|
Loading…
Add table
Reference in a new issue