Handlebars
@vituum/vite-plugin-handlebars
<ul id="navigation">
{{#each navigation as |item|}}
<li>{{ item }}</li>
{{/each}}
</ul>
<ul id="navigation">
{{#each navigation as |item|}}
<li>{{ item }}</li>
{{/each}}
</ul>
See docs for more info about the syntax
Install
npm
npm i @vituum/vite-plugin-handlebars --save-dev
npm i @vituum/vite-plugin-handlebars --save-dev
yarn
yarn add @vituum/vite-plugin-handlebars -D
yarn add @vituum/vite-plugin-handlebars -D
Config
import handlebars from '@vituum/vite-plugin-handlebars'
export default {
plugins: [handlebars()]
}
import handlebars from '@vituum/vite-plugin-handlebars'
export default {
plugins: [handlebars()]
}
Options
reload
- Type:
boolean
orFunction
- Default:
true
Whenever to auto-reload browser window upon hbs
or json
file change. You can also provide function to filter upon which file a reload should occur.
root
- Type:
string
- Default:
null
Root is inherited from Vite root
by default. But you can change this to path such as './src/'
or './src/templates'
, then you can use includes with paths defaulting to this directory.
helpers
- Type:
Object
- Default:
{}
Object of named helper functions to use, see Handlebars docs for more info.
partials.directory
- Type:
string
- Default:
null
Root directory for partials. Directory is inherited from plugin root
by default.
partials.extname
- Type:
boolean
- Default:
true
Whenever to use ext-name in partial path like this "path/to/partial.hbs
data
- Type:
string
- Default:
['src/data/**/*.json']
Path to additional data provided with json file. Can be a file, or a glob like this /path/to/*.jsom
.
globals
- Type:
Object
- Default:
{}
Other global data to use. Can be Object
or function
returning object, or combination of both.
ignoredPaths
- Type:
string[]
- Default:
[]
Which paths should be ignored from processing as TwigJS.
formats
- Type:
string[]
- Default:
['hbs', 'json.hbs', 'json']
Which ext-names should be processed by the plugin.
options.compileOptions
- Type:
Object
- Default:
{}
Additional Handlebars compileOptions, see Handlebars docs for more info.
options.runtimeOptions
- Type:
Object
- Default:
{}
Additional Handlebars runtimeOptions, see Handlebars docs for more info.