Preproc.js
Preproc.js is the anything preprocessor for node.js. Preprocess any file performing inclusions and conditional compilation.
Installation
npm install preproc
Usage
Include everything everywhere
//= include "mylib.coffee"MyLib;
Define delimiters for each file format and choose how to transform sources before they are included into other files
var preproc = ;var builder =types:coffeescript:delimiters: "#="extensions: '.coffee'to:{return coffee;}javascript:delimiters: "//="extensions: '.js'to:{return ";" + content + ";";}{return "\`" + content + "\`\n";}{return "<script>\\\\<![CDATA[\n" + content + "\n\\\\]]></script>";}html:delimiters: "<!--=" "-->"extensions: '.html';
Note: Preproc.js ships with a default configuration. See https://github.com/mcasimir/preprocjs/blob/master/src/defaults.coffee for more.
Use Path Globbing to include multiple files at once
My App<!--= include "templates/*.hbs" -->
Require something once
//= require "mylib.js"
Skip precompilation on unknown sources
//= require "vendor/lib.js" --skip
Environment
Variables
builder;
var myVal = ;//= if debugconsole;//= end
Conditional Compilation
//= if target == 'client'$;//= else if target == 'server'Db;//= end
Operators
- ! or not
- & or and
- || or or
- < or lt
- > or gt
- <= or lte
- >= or gte
- == or eq
- != or neq
Give it a try
npm install preproc
Read http://mcasimir.github.io/preprocjs/getting_started.html for more
Copyright (c) 2013 mcasimir
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.