ejs
ejs copied to clipboard
How to correctly use function in templates
I now write the function to the template data call ,because I didn't find the relevant documents. I write this right now, I don't know if it's correct, I hope to get help, thank you.
const ejs = require('ejs')
ejs.delimiter = '%'
var result = ejs.render('<%= capitalize(title) %>', {
title: 'test',
capitalize(str) {
return str ? str.substring(0, 1).toUpperCase() + str.substring(1) : str
}
})
console.log(result) //Test