Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to correctly use function in templates #378

Open
yimogit opened this issue May 24, 2018 · 0 comments
Open

How to correctly use function in templates #378

yimogit opened this issue May 24, 2018 · 0 comments

Comments

@yimogit
Copy link

yimogit commented May 24, 2018

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant