/bowtie-js.github.com

Documentation for bowtie template engine

Primary LanguageHTML

About Bowtie

Expressive template engine for Node.js heavily inspired by Jade.

Goals

This project aims to develop an expressive template language to write html documents using the dry and kiss principles. And of course, remove the pain of writing angle brackets.

Current status

This project is currently in it's pre-alpha stage. Current features:

  • Loops
  • If-Else
  • Mixins
  • Extending
  • Importing

Getting started

Installation

$ npm install bowtie-js

Syntax highlighting

Syntax highlighting and auto completion is available for Atom editor. Syntax highlighting is triggered on .bow-files.

Install:

$ apm install atom-language-bowtie

Usage with gulp

Gulp compatible compiling comes out of the box with Bowtie, example:

var gulp = require('gulp');
var bowtie = require('bowtie-js').gulp;

gulp.task('bowtie', function() {
  return gulp.src('*.bow')
    .pipe(bowtie({
      // Pretty output
      "pretty": true,
      // Object to pass to template engine
      "locals": {
        "title": "Example application"
      }
    }))
    .pipe(gulp.dest('./dist'));
});

Language reference

Attributes

Attributes are provided in the same way as good old HTML, within parenthesis.

a(href="#" role="button"): "Foo bar"

Results in

<a href="#" role="button">Foo bar</a>

Class and ID literals

div#foo.bar {
  p: "Content"
}
<div id="foo" class="bar">
  <p>Content</p>
</div>

Comments

Comments are used as in javascript

// comment

No multi line comments are available at this point though.

Conditionals

Conditionals are used as in javascript

if (expr) {
  div#foo.bar {
    p: "True!"
  }
} else {
  div#bar.foo {
    p: "False!"
  }
}

Doctype

!doctype("html")

Includes

Includes are used by using the import keyword

html {
  head {
    import "head.bow"
  }
}

Inheritance

Interpolation

Iteration

Mixins

Tags