Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alosaur/handlebars
Handlebars template engine for Deno
https://github.com/alosaur/handlebars
deno handlebars html
Last synced: 1 day ago
JSON representation
Handlebars template engine for Deno
- Host: GitHub
- URL: https://github.com/alosaur/handlebars
- Owner: alosaur
- License: mit
- Created: 2020-05-02T23:22:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-17T15:56:47.000Z (4 months ago)
- Last Synced: 2024-10-29T16:13:39.974Z (10 days ago)
- Topics: deno, handlebars, html
- Language: TypeScript
- Homepage:
- Size: 43.9 KB
- Stars: 30
- Watchers: 2
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-deno - handlebars - Handlebars template engine for deno (Modules / Template engine)
README
## Handlebars template render for Deno
![test](https://github.com/alosaur/handlebars/workflows/test/badge.svg)
Official handlebars docs: [Guide](https://handlebarsjs.com/guide)
### How to use renderer
```ts
import { Handlebars, HandlebarsConfig } from 'https://deno.land/x/handlebars/mod.ts';// First, create instance of Handlebars
const handle = new Handlebars();
// or with custom config
const handle = new Handlebars({
...
});// by default uses this config:
const DEFAULT_HANDLEBARS_CONFIG: HandlebarsConfig = {
baseDir: 'views',
extname: '.hbs',
layoutsDir: 'layouts/',
partialsDir: 'partials/',
cachePartials: true,
defaultLayout: 'main',
helpers: undefined,
compilerOptions: undefined,
};// Then render page to string
const result: string = await handle.renderView('index', { name: 'Alosaur' });
```#### Rendering in development mode
By default partials are registered (and so cached) the first time you call
`renderView`. However, in development, it may be better to re-register them
every time you render a view so that the rendering reflects the latest changes
you have made to your partials.You can ensure this happens by setting `cachePartials` to be false in your
configuration.