Skip to content

alexy-os/handlebars-bunjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

buildy hbs with bun

To install dependencies:

bun install

To run:

bun start

Usage

import { setConfig, initHandlebars, render } from 'bun-hbs';
import { join } from 'path';

// Configuring the configuration
setConfig({
  VIEWS_DIR: join(__dirname, 'views'),
  PARTIALS_DIR: join(__dirname, 'views/partials'),
  LAYOUTS_DIR: join(__dirname, 'views/layouts'),
  LOG_LEVEL: 'debug'
});

// Initializing the template engine
await initHandlebars();

// Rendering a template
const result = await render('home.hbs', { title: 'Home' }, 'main.hbs');
console.log(result);

This project was created using bun init in bun v1.1.27. Bun is a fast all-in-one JavaScript runtime.