Skip to content

Commit

Permalink
fix: add a lambda function in the template to allow users to format date
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed Sep 28, 2023
1 parent 1f34694 commit 0a18943
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @jacksonh @rupin90 @satindar @sywhb
* @jacksonh @satindar @sywhb
11 changes: 11 additions & 0 deletions src/settings/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,21 @@ function upperCaseFirst() {
};
}

function formatDateFunc() {
return function (text: string, render: (text: string) => string) {
// get the date and format from the text
const [dateVariable, format] = text.split(",", 2);
const date = render(dateVariable);
// format the date
return formatDate(date, format);
};
}

const functionMap: FunctionMap = {
lowerCase,
upperCase,
upperCaseFirst,
formatDate: formatDateFunc,
};

export const renderFilename = (
Expand Down

0 comments on commit 0a18943

Please sign in to comment.