Skip to content

Commit

Permalink
VA-16652: Add liquid filter for phone extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
maxx1128 committed Feb 29, 2024
1 parent c0650cf commit 1efab75
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/site/filters/liquid.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,26 @@ module.exports = function registerFilters() {
return data;
};

liquid.filters.separatePhoneNumberExtension = phoneNumber => {
if (!phoneNumber) {
return null;
}

if (!phoneNumber.includes(', ext. ')) {
return {
phoneNumber,
extension: null,
};
}

const splitNumber = phoneNumber.split(', ext. ');

return {
phoneNumber: splitNumber[0],
extension: splitNumber[1],
};
};

liquid.filters.trackLinks = (html, eventDataString) => {
// Add calls to "recordEvent" to all links found in html
const eventData = JSON.parse(eventDataString);
Expand Down Expand Up @@ -867,7 +887,7 @@ module.exports = function registerFilters() {

/**
* Converts a string to camel case and removes a prefix
@param {string} prefix - prefix to be removed - make empty string not to change string
@param {string} prefix - prefix to be removed - make empty string not to change string
@param {string} string - string to be converted
*/
liquid.filters.trimAndCamelCase = (toRemove, string) => {
Expand Down

0 comments on commit 1efab75

Please sign in to comment.