sindresorhus / pupa

Simple micro templating
MIT License
362 stars 22 forks source link

Support functions in templates #12

Closed azabroflovski closed 4 years ago

azabroflovski commented 4 years ago

Hi, u can add support functions in templates?

Example:

const template = 'Some string via { obj.method() }'

const data = {
 obj: { 
  method: () => 'great function' 
 } 
}

pupa(template, data)
sindresorhus commented 4 years ago

No, sorry. I don't plan to go down that (messy) road. If you don't need any method parameters. You can just make it a getter instead:

const template = 'Some string via { obj.method }'

const data = {
 obj: { 
  get method() {
    return 'great function'
  }
 } 
}

pupa(template, data)