Giter Site home page Giter Site logo

blueprints's Introduction

blueprints is a JavaScript template library for generating DOM elements. It takes a directory and converts it into a namespaced template library.

Installation

npm install blueprints

Usage

Create a template file with a .html extension (can be changed through options object see below) for this example we will name this file list.html. Place this file in a root directory and then compile it using one of the methods below.

root_dir/list.html

<div class="## if (something) { ##a-class## } ##">
   ## for (var i = 0, l = xs.length; i < l; i++) { ##
   <span>##= xs[i].name##</span>
   ## } ##
</div>

When you include your compiled template library in your javascript web app you will be able to access it using the window.blueprints function passing in the id of the template and data to be used in the template.

var element = window.blueprints('list', { 
   something: true, 
   xs: [ { name:'foo' }, { name:'bar' } ] 
});

Here is a slightly more compiles template directory and the ids that correspond to the different files.

root_dir/list.html                       list
root_dir/reports/table.html              reports:table
root_dir/reports/structure.html          reports:structure
root_dir/reports/daily/breakdown.html    reports:daily:breakdown

Compilation

Through a terminal:

$ blueprints {directory}

will out the template file to stdout

$ blueprints {directory} -o {file}

will out the template file to the specified file

$ blueprints -m {directory}

will minify the template file before outputting it

As a module:

var blueprints = require('blueprints');

new blueprints(path, { minify: true }).out(writeable_stream);

blueprints's People

Contributors

tombooth avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

steveukx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.