Skip to content

Commit

Permalink
feat: ended templates
Browse files Browse the repository at this point in the history
  • Loading branch information
hrenaud committed Nov 29, 2023
1 parent 1b1b507 commit 6a942bf
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 473 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.handlebars
14 changes: 13 additions & 1 deletion lighthouse-plugin-ecoindex/cli/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import { convertCourseResults } from './converters.js'
const SEPARATOR = '\n---------------------------------\n'
const __dirname = fileURLToPath(dirname(import.meta.url))

Handlebars.registerHelper('toDateString', function (date) {
const _date = new Date(date)
return _date.toDateString()
})
Handlebars.registerHelper('plus1', function (n) {
return Number(n) + 1
})
Handlebars.registerHelper('ifEquals', function (arg1, arg2, options) {
return arg1 == arg2 ? options.fn(this) : options.inverse(this)
})

/**
* Prepare folder and naming files.
* @param {object} cliFlags
Expand Down Expand Up @@ -144,7 +155,8 @@ async function printEnvStatementDocuments(cliFlags) {
)
const templateMD = Handlebars.compile(sourceMD)
const mdContent = templateMD(JSON.parse(jsonFile))
writeFileSync(envStatementsObj.statements.html, mdContent)
console.log(`mdContent`, mdContent)
writeFileSync(envStatementsObj.statements.md, mdContent)
console.log(
`Environnemental statement generated: ${envStatementsObj.statements.md}`,
)
Expand Down
Loading

0 comments on commit 6a942bf

Please sign in to comment.