nunjucks-in-yaml
A YAML extension to use documents in YAML as Nunjucks templates.
Install
npm i nunjucks-in-yaml
Template example
A template files are --- # {name}
-separated YAML and nunjucks templates.
First section is YAML. Nunjucks templates follows it.
from: from@me.email
subject: Thank you for your message!
---
Hi {{ user.name }},
Thank you for your message.
Best regards,
---
Hi <b>{{ user.name }}<b>,
Thank you for your message.
Best regards,
Usage
const loader = require('nunjucks-in-yaml')
const user = {
name: 'Kurara',
email: 'kurara@xx.email'
}
const obj = loader.renderSync('test.yml', { user })
console.log(obj)
Examples
View here