Getting Started

Installation

npm install preproc

Usage

Preproc.js is used to concatenate files and perform conditional compilation of code using macros in a similar way to c/c++ preprocessor.

preproc = require('preproc')

builder = new preproc.Builder
  env:
    name: "My App"
    test: 10

  types:
    coffeescript:
      delimiters: ["#="]
      extensions: ['.coffee']

      to: 
        javascript: (content) ->
          coffee = require 'coffee-script'
          coffee.compile(content)

    javascript:
      delimiters: ["//="]
      extensions: ['.js']

      to: 
        javascript: (content) ->
          ";#{content};"
        coffeescript: (content) ->
          "\`#{content}\`"
        html: (content) ->
          "<script>\\\\<![CDATA[\n#{content}\n\\\\]]></script>"

    html:
      delimiters: ["<!--=", "-->"]
      extensions: ['.html', '.hbs']


builder.build "test.coffee", "test.js"

title = "#= print name"

#if test == 10
console.log title

#else
#= include <lib.js>

#end

Copyright (c) 2013 mcasimir