node package manager


TopRope Build Status

A handlebars template compiler for directories using hogan.js, and renderer for express.


npm install toprope


TopRope is meant to be used in conjunction with express to render your compiled templates to a view in an isolated script tag.

In your node.js express app

express = require "express"
topRope = require "toprope"

myApp = express()

topRope process.cwd() + "/public/templates", (err, scriptTag) ->
  app.listen 3000, (err) -> 
  	console.log "Listening on 3000, Ctrl-C to exit"

This will compile all the templates in your /public/templates directory.

In your view (jade templates example)

<script src=""></script>
!= templates()

This will output a <script> tag containing the APPLICATION_TEMPLATES variable with your templates.

Rendering your template

var hoganed = new Hogan.Template(APPLICATION_TEMPLATES["someTemplate.hbs"]),
    html = hoganed.render({ data: "something" });

First we have to 'Hoganize' the template then call render on it.


Created by Jacob Gable. Licensed under the MIT License; no attribution required.