npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

brick-hbs

v2.0.4

Published

Handlebars Template Engine for Brick.js

Downloads

6

Readme

NPM version Build Status Coverage Status Dependency manager

Handlebars Template Engine for Brick.js.

Run the Demo

demo/ directory contains a demo project. Run the demo:

git clone [email protected]:brick-js/brick-hbs.git
cd brick-hbs && npm install
cd demo && npm install
grunt

Open http://localhost:3000 in your browser!

Installation

npm install -S brick-hbs

Set template engine for brick.js

var brickJs = require('brick.js');
var Hbs = require('brick-hbs');

var brk = brickJs();

var hbs = Hbs.brick({
    cache: false    // disabled by default, see below
})
brk.engine('.hbs', hbs);     // set hbs engine for .hbs file
brk.engine('.html', hbs);    // set hbs engine for .html file

app.use('/', brk.express);

Include Partials/Modules

In Brick.js, partials are organized as modules. Eg:

File footer/view.hbs in module footer:

<footer> Powered by Brick.js </footer>

File home/view.hbs in module home:

<html>
<body>
  <p>Demo Page</p>
  {{include 'footer'}}
</body>
</html>

The HTML for home page will be rendered as:

<html>
<body>
  <p>Demo Page</p>
  <footer> Powered by Brick.js </footer>
</body>
</html>

Layout Extend

Brick-hbs implemented async helper internaly, to support layout extend. Eg:

File layout1/view.html in module layout1:

<html>
<title>Common Title</title>
<body>
  {{{block}}}
</body>
</html>

Use {{block}} for escaping.

File home/view.hbs in module home:

{{extend 'layout1'}}
<p> Contents for home page </p>

The HTML for home page will be rendered as:

<html>
<title>Common Title</title>
<body>
  <p> Contents for home page </p>
</body>
</html>

Options

cache

Type: Bool

Default: false

If set to true, all templates will be loaded only once (for production usage). Otherwise, template file will be reloaded on every HTTP request.

Register New Helper

Above declared Hbs object is compatible with Handlebars.

Javascript:

Hbs.registerHelper('upperCase', function(content) {
    return content.toUpperCase();
});

Template:

<h3>{{upperCase 'alice'}}</h3>

Will be rendered as:

<h3>ALICE</h3>