0.1.0 • Published 12 years ago

liz v0.1.0

Weekly downloads
2
License
-
Repository
github
Last release
12 years ago

#Macho

Macho lets you organize your JS templates in any file and directory structure that you want, and compiles all your templates into one tight JS file when run.

Macho is specially built to work with Hogan.js, but it can be adapted to help you with plain Mustache (or any other) templating engine. It derives heavily from and is a lot like hulk, except that you don't need to have one template per file.

##Usage

$ npm install macho -g
$ macho <input_path> <output_file>

For instance, if you've got ####templates/users.html

<template name="user.greeting">
    <p>Hello, {{name}}</p>
</template>

<script name="user.outro" type="text/x-mustache">
    </p></div>And that's the end of it.
</script>

Using template tags is easier - most editors will continue to give you HTML syntax highlighting and help. Or you can use script tags like John Resig says; especially when you're writing templates that don't validate as HTML.

Running

$ macho templates/**/*.html templates.js

should give you

####templates.js module.exports.user = {}; module.exports.user.greeting = new Hogan.Template(function(c,p,i){var =this;.b(i=i||"");.b("Hello, ");.b(.v(.f("name",c,p,0)));.b("");return .fl();;}); module.exports.user.outro = new Hogan.Template(function(c,p,i){var =this;.b(i=i||"");.b("And that's the end of it.");return .fl();;});