Linting and updating helper manifest.

This commit is contained in:
mike12345567 2021-02-04 10:25:04 +00:00
parent a86b6db772
commit 008c9dcbcd
4 changed files with 20 additions and 10 deletions

View File

@ -1097,8 +1097,17 @@
"format"
],
"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"
},
"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"],
numArgs: 2,
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) {

View File

@ -64,12 +64,12 @@ function initialSteps(str, pattern, options) {
pattern = null
str = null
}
return {str, pattern, options}
return { str, pattern, options }
}
function setLocale(str, pattern, options) {
// 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 opts = getContext(this, defaults, options)
@ -78,7 +78,7 @@ function setLocale(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 (str == null && pattern == null) {
@ -92,7 +92,7 @@ module.exports.date = (str, pattern, options) => {
}
module.exports.duration = (str, pattern, format) => {
({str, pattern} = initialSteps(str, pattern))
;({ str, pattern } = initialSteps(str, pattern))
setLocale(str, pattern)

View File

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