This helper allows to render a nitro component using handlebars
npm i --save-dev @namics/nitro-component-handlebars
const componentHandlebarsHelper = require('@namics/nitro-component-handlebars');
module.exports = componentHandlebarsHelper({
rootDirectory: '/path/to/nitro/root'
})
The following code will render components/atoms/button/button.hbs
:
{{component "components/atoms/button"}}
The following code will set the value of {{children}}
to 'Click me'
:
{{#component "components/atoms/button"}}
Click me
{{/component}}
The following code will set the value of {{size}}
to 'xl'
:
{{component "components/atoms/button" size="xl"}}
The following code will set the value of {{sizes}}
to ['xl', 'l']
:
{{component "components/atoms/button" sizes="['xl', 'l']"}}
The following code will set the template variables to the content of
components/atoms/button/_data/demo.json
:
{{component "components/atoms/button" data-file="demo.json"}}
The following code will render a component from another node_module
e.g. node_modules/base-pattern/components/atoms/button/button.json
{{component "~base-pattern/components/atoms/button"}}
You're free to contribute to this project by submitting issues and/or pull requests. This project is test-driven, so keep in mind that every change and new feature should be covered by tests. This project uses the .
This project is licensed under MIT.