Linting and updating helper manifest.

This commit is contained in:
mike12345567 2021-02-04 10:25:04 +00:00
parent 821fb20e8b
commit 1a9d6bcb60
4 changed files with 20 additions and 10 deletions

View File

@ -1097,8 +1097,17 @@
"format" "format"
], ],
"numArgs": 2, "numArgs": 2,
"example": "{{date now \"DD-MM-YYYY\"}}", "example": "{{date now \"DD-MM-YYYY\"}} -> 21-01-2021",
"description": "<p>Format a date using moment.js date formatting.</p>\n" "description": "<p>Format a date using moment.js date formatting.</p>\n"
},
"duration": {
"args": [
"time",
"durationType"
],
"numArgs": 2,
"example": "{{duration timeLeft \"seconds\"}} -> a few seconds",
"description": "<p>Produce a humanized duration left/until given an amount of time and the type of time measurement.</p>\n"
} }
} }
} }

View File

@ -26,9 +26,10 @@ const ADDED_HELPERS = {
args: ["time", "durationType"], args: ["time", "durationType"],
numArgs: 2, numArgs: 2,
example: '{{duration timeLeft "seconds"}} -> a few seconds', example: '{{duration timeLeft "seconds"}} -> a few seconds',
description: "Produce a humanized duration left/until given an amount of time and the type of time measurement." description:
} "Produce a humanized duration left/until given an amount of time and the type of time measurement.",
} },
},
} }
function fixSpecialCases(name, obj) { function fixSpecialCases(name, obj) {

View File

@ -64,12 +64,12 @@ function initialSteps(str, pattern, options) {
pattern = null pattern = null
str = null str = null
} }
return {str, pattern, options} return { str, pattern, options }
} }
function setLocale(str, pattern, options) { function setLocale(str, pattern, options) {
// if options is null then it'll get updated here // if options is null then it'll get updated here
({str, pattern, options} = initialSteps(str, pattern, options)) ;({ str, pattern, options } = initialSteps(str, pattern, options))
const defaults = { lang: "en", date: new Date(str) } const defaults = { lang: "en", date: new Date(str) }
const opts = getContext(this, defaults, options) const opts = getContext(this, defaults, options)
@ -78,7 +78,7 @@ function setLocale(str, pattern, options) {
} }
module.exports.date = (str, pattern, options) => { module.exports.date = (str, pattern, options) => {
({str, pattern, options} = initialSteps(str, pattern, options)) ;({ str, pattern, options } = initialSteps(str, pattern, options))
// if no args are passed, return a formatted date // if no args are passed, return a formatted date
if (str == null && pattern == null) { if (str == null && pattern == null) {
@ -92,7 +92,7 @@ module.exports.date = (str, pattern, options) => {
} }
module.exports.duration = (str, pattern, format) => { module.exports.duration = (str, pattern, format) => {
({str, pattern} = initialSteps(str, pattern)) ;({ str, pattern } = initialSteps(str, pattern))
setLocale(str, pattern) setLocale(str, pattern)

View File

@ -19,8 +19,8 @@ const EXTERNAL_FUNCTION_COLLECTIONS = [
] ]
const ADDED_HELPERS = { const ADDED_HELPERS = {
"date": date, date: date,
"duration": duration, duration: duration,
} }
exports.registerAll = handlebars => { exports.registerAll = handlebars => {