Skip to content

Commit

Permalink
refactor: summary string transformations code to pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
hip3r committed Oct 24, 2024
1 parent b9cc84e commit 018ea1d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/decap-cms-lib-widgets/src/stringTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const filters = [
];

const FIELD_PREFIX = 'fields.';
const templateContentPattern = '([^}{|]+)';
const filterPattern = '( \\| ([^}{]+))?';
const templateContentPattern = ' *([^}{| ]+)';
const filterPattern = '( \\| ([^}{]+?))? *';
const templateVariablePattern = `{{${templateContentPattern}${filterPattern}}}`;

// prepends a Zero if the date has only 1 digit
Expand Down Expand Up @@ -175,12 +175,6 @@ export function compileStringTemplate(
RegExp(templateVariablePattern, 'g'),
(_full, key: string, _part, filter: string) => {
let replacement;
if (key) {
key = key.trim();
}
if (filter) {
filter = filter.trim();
}
const explicitFieldReplacement = getExplicitFieldReplacement(key, data);

if (explicitFieldReplacement) {
Expand Down

0 comments on commit 018ea1d

Please sign in to comment.