Skip to content

Handlebars template engine for Deno

License

Notifications You must be signed in to change notification settings

marianpg/handlebars

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Handlebars template render for Deno

test

Official handlebars docs: Guide

How to use renderer

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.

About

Handlebars template engine for Deno

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 93.4%
  • Handlebars 6.6%