a next-gen language watcher/compiler for pre-processed languages

npm install giles
24 downloads in the last week
99 downloads in the last month
<p>Giles wants you to stop writing HTML, CSS, and JS. </p>

<p>Giles is a static asset builder for a variety of useful markup languages.  Use Giles to develop with 
nextgen web tools and increase project momentum.</p>

<h2>Giles supports</h2>

<li><a href="">CoffeeScript</a> - Incredible javascript compiler.  Everything just seems to work better with coffeescript. </li>
<li><a href="">Stylus</a> - Fantastic css compiler.  The variable/mixin support is extremely powerful.</li>
<li><a href="">Jade</a> - Cool HAML-like alternative to writing html.</li>
<li><a href="">Markdown</a> - Markdown is the most intuitive markup language ever invented.</li>
<li>Your favorite language.  Add it and issue a pull request.</li>

<h3>Giles is a command line tool and API for:</h3>

<li>Developing.  Watch a directory using the <code>giles -s</code> command, and build files as they are requested.</li>
<li>Releasing.  Building static assets for deployment </li>

<p>The goal of Giles is not to advocate a specific framework, rather to provide developers and designers
functionality in the languages of their choice.</p>

<h3>To install run</h3>

sudo npm install -g giles

<p><em>npm is available by installing <a href="">nodejs</a></em></p>

<h3>To build static assets, recursively</h3>


<p><em>It will build every file into the same directory(views/index.jade will become views/index.html)</em></p>

<p><em>Giles ignores files that begin with '</em>' (underscore).  Use these for mixins, partials and etc. _</p>

<h3>To get help</h3>

giles -h

<p><em>If you ever need to run this, file a bug with me.</em></p>

<h3>To clean up</h3>

giles -c
<em>This will remove all files where generation is possible - IE: it will remove layout.html if you have a layout.jade.  Be safe out there!</em></p>

###To watch the current directory, recursively 
    giles -w
_Handles new files too.  It will work even if you re-arrange your whole project._

###To watch a specific directory, recursively 
    giles directory -w
_This compiles to the same directory as the asset._
###To build all assets recursively, outputting to a specific directory 
    giles -o build

<h3>To ignore a directory, or multiple(will match recursively)</h3>

giles --ignore vendor,bin

<p><em>ignore defaults to node</em>modules,.git_</p>

<h3>To start a webserver on port 9000</h3>

giles -s -p 9000
<em>-p is optional, and will default to 2255 if not specified</em></p>


<pre><code>Note the flag -e is deprecated in favor of the NODE_ENV environment variable.

<p>Environments are shortcuts that allow you to treat compilations differently. 
<em>giles defaults to null if unspecified.</em></p>

NODE_ENV=production giles &lt;dir&gt;

<p>Compile assets in <directory> in production mode.</p>

<p>Jade assets (and all compiled types that support local variables) can contain tests for the environment:</p>

- if(environment == 'production')
  #prodOnly content


<p>These examples are in coffeescript.</p>

<h3>Building with .js and giles (works with Jake or Cake)</h3>

srcDir = PATH<em>TO</em>SOURCE
options = {}</p>

<p>giles = require('giles'), options)

### To watch with giles 
    srcDir = PATH_TO_SOURCE
    options = {}

    giles = require('giles'), options)

<h3>To run the giles server</h3>

giles = require('giles')
giles.server(dir, {port : 12345})

<p><em>Try it for a lightweight development mode</em></p>

<h3>To use giles connect/express module</h3>


<p>This connector will compile supported file types (index.jade will be compiled when index.html is requested).  It does not serve any files.</p>

<p><em>It is imperative that you place this before `connect.static'</em></p>

<h3>Adding a custom route</h3>

<p>By default giles creates a 1-1 map of template to generated page.  This allows you to use the same jade file with separate variables
to generate a dynamic page that is built into a finite amount of static targets.</p>


<h1>This generates static files with the output file dynamicPage.html</h1>

<h1>locals is a list of variables available</h1>

<h1>to the .jade file when running this action</h1>

<p>locals = {name : "Martyn"}</p>

<p>giles.get '/dynamicPage.html', 'page.jade', locals

<p><em>Then in page.jade</em></p>

  title = name

<h3>To add a compiler to giles</h3>

coffee = require 'coffee-script'
giles.addCompiler ['.coffee', '.cs'], '.js', (contents, filename, output) -&gt;
  output(coffee.compile(contents, {}))

<h4>Or for stylus</h4>

stylus = require 'stylus'
giles.addCompiler [".styl", ".stylus"], '.css', (contents, filename, output) -&gt;
  stylus.render contents, {filename: filename}, (err, css) -&gt;
    if err
      console.error "Could not render stylus file: "+filename
      console.error err

<p><strong>Both of these compilers are already in giles and listed here for illustration purposes.</strong></p>



<li>Added mocha specs around connect module</li>
<li>Merged issue with mime types from <a href="">mbarzda</a></li>


<li>Added giles -q (--quiet)</li>


<li>Added giles -c (--clean)</li>


<li>Added markdown</li>
<li>Fixed a bug in coffeescript generation</li>


<li>Added -v flag to output version number</li>


<li>Added -e flag for environments</li>
<li>Documentation slightly updated</li>


<li>Added <code>giles.get("/route", sourceFile, locals)</code> for defining generated files</li>
<li>Added -s option which tells giles to start a webserver on port 2255</li>
<li>Added -p option to specify port of -s</li>
<li>Removed -w option, -s works better and more consistently</li>


<p>Giles is available under the MIT license.  We hope you find it useful.  Please let us at 255 BITS know if you use it for something cool.</p>

<p><em>Into every generation a slayer is born: one girl in all the world, a Chosen One.  One born with the strength and skill
to fight the vampires, to stop the spread of their evil and swell of their numbers.</em></p>
npm loves you