Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed May 29, 2011
1 parent 980101a commit e5bee71
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions README.md
@@ -1,29 +1,28 @@
# domjs - Client and server side dom template engine
# domjs - client and server side dom template engine

Build dom structure easy way with plain JavaScript.
Can be used on both client and server side.
Due to its small footprint it suits small projects best.
Build dom structure easy way with plain JavaScript. Can be used on both client
and server side. Due to its small footprint it's best suited for small projects.

## Instalation

When using node:

$ npm install domjs

_Instructions for browser side installation coming soon._
_Instructions for browser side installation on the way._

## Usage

What would be the easiest, most intuitive way to build html5 DOM tree with
plain JavaScript ?
What would be the easiest, most intuitive way to build html5 DOM tree with plain
JavaScript ?

var mytemplate = function () {
header(
h1('Heading'),
h2('Subheading'));

nav(
ul({ class: 'breadcrumbs' },
ul({ 'class': 'breadcrumbs' },
li(a({ href: '/' }, 'Home')),
li(a({ href: '/section/'}, 'Section')),
li(a('Subject'))));
Expand All @@ -34,8 +33,10 @@ plain JavaScript ?
footer('Footer stuff');
};

This is how templates for domjs are written. To get `mytemplate` function
content turned into DOM (literally DocumentFragment):
This is how templates for domjs are written.

To get `mytemplate` function content turned into DOM
(literally _DocumentFragment_):

var domjs = require('domjs/lib/html5')(document);

Expand All @@ -55,7 +56,7 @@ You can save references to elements and operate on them later:
// append myul into other element
div(myul);

You can access DOM elements directly, just invoke returned function with no
You can access DOM elements directly, just invoke returned function with no
arguments

(myul() instanceof DOMElement) === true
Expand All @@ -72,8 +73,8 @@ Text nodes in main scope:

_text('my text');

Elements with names that are reserved keywords in JavaScript language,
like 'var', should be created with preceding underscore added to its name:
Elements with names that are reserved keywords in JavaScript language, like
'var', should be created with preceding underscore added to its name:

_var('var content');

Expand Down

0 comments on commit e5bee71

Please sign in to comment.