ejs icon indicating copy to clipboard operation
ejs copied to clipboard

How to correctly use function in templates

Open yimogit opened this issue 7 years ago • 0 comments

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

yimogit avatar May 24 '18 05:05 yimogit