bminer / node-blade

Blade - HTML Template Compiler, inspired by Jade & Haml
Other
320 stars 28 forks source link

can you run blade just on the client? #166

Closed nkhine closed 11 years ago

nkhine commented 11 years ago

hi, is it possible to compile all the blade templates and host these on say gh-pages as a static type site?

bminer commented 11 years ago

No. The Blade compiler is designed exclusively for Node.js; however, with a few tweaks, it could run on the browser, I suppose. The parser is browser-compatible out-of-the-box, but the compiler uses Node libraries like path and fs along with the require() function.

bminer commented 11 years ago

To answer your other question... "is it possible to compile all the blade templates and host these on say gh-pages as a static type site?"

Yes, you can compile templates with the Blade command-line tool and serve them as static files.

nkhine commented 11 years ago

great! what would be the command line to compile these templates? thanks

bminer commented 11 years ago

Output of blade --help:


  Usage: blade [options] source_path destination_path

  Options:

    -h, --help                output usage information
    -V, --version             output the version number
    -R, --render              renders the template and outputs HTML (default)
    -C, --compile             compile-only: output the compiled template
    -l, --locals <str>        JSON string to be used as the locals object
    -L, --locals-file <file>  require() path to a module exporting locals obj
    -o, --compile-opts <str>  JSON string to be used as the compiler's options
    -d, --debug               sets the compiler's debug option
    -m, --minify              sets the compiler's minify option
    --no-include-source       clears the compiler's includeSource option

Renders or compiles Blade templates.

If a filename is `-` instead of an actual path, read from standard input or
write to standard output.
includeSource compiler option is set by default.

Examples:

        Render a Blade template to stdout from stdin using the local variables
        exported in a Node module (i.e. ./locals.js):
        $ blade -L ./locals - -

        Render a Blade template to stdout from stdin using the locals provided
        $ blade -l '{"author":"Blake Miner"}' - -

        Compile foo.blade and output the minified template to stdout:
        $ blade -C -m foo.blade -

        Compile and minify an entire directory of *.blade files:
        $ blade -C -m ./views ./public/views