From ac4986b620c090d80b68c46b84806e6f2cf8baaf Mon Sep 17 00:00:00 2001 From: Caleb John Date: Thu, 29 Aug 2019 10:35:43 -0600 Subject: [PATCH] Desktop: Fixes #1803: Use correct date format for templates (#1810) --- ReactNativeClient/lib/TemplateUtils.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/ReactNativeClient/lib/TemplateUtils.js b/ReactNativeClient/lib/TemplateUtils.js index 2986cee2f..acc79edb2 100644 --- a/ReactNativeClient/lib/TemplateUtils.js +++ b/ReactNativeClient/lib/TemplateUtils.js @@ -4,18 +4,6 @@ const Mustache = require('mustache'); const TemplateUtils = {}; -// new template variables can be added here -// If there are too many, this should be moved to a new file -const view = { - date: time.formatMsToLocal(new Date().getTime(), time.dateFormat()), - time: time.formatMsToLocal(new Date().getTime(), time.timeFormat()), - datetime: time.formatMsToLocal(new Date().getTime()), - custom_datetime: () => { - return (text, render) => { - return render(time.formatMsToLocal(new Date().getTime(), text)); - }; - }, -}; // Mustache escapes strings (including /) with the html code by default // This isn't useful for markdown so it's disabled @@ -24,6 +12,20 @@ Mustache.escape = text => { }; TemplateUtils.render = function(input) { + // new template variables can be added here + // If there are too many, this should be moved to a new file + // view needs to be set in this function so that the formats reflect settings + const view = { + date: time.formatMsToLocal(new Date().getTime(), time.dateFormat()), + time: time.formatMsToLocal(new Date().getTime(), time.timeFormat()), + datetime: time.formatMsToLocal(new Date().getTime()), + custom_datetime: () => { + return (text, render) => { + return render(time.formatMsToLocal(new Date().getTime(), text)); + }; + }, + }; + return Mustache.render(input, view); };