<commit_before># 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's best suited for small projects.

## Instalation

When using node:

	$ npm install domjs

_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 ?

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

		nav(
			ul({ 'class': 'breadcrumbs' },
				li(a({ href: '/' }, 'Home')),
				li(a({ href: '/section/'}, 'Section')),
				li(a('Subject'))));

		article(
			p('Lorem ipsum...'));

		footer('Footer stuff');
	};

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);

	var mydom = domjs(mytemplate);

### Other notes

You can save references to elements and operate on them later:

	var myul = ul(li('one'), li('two'), li('three'));

	// ... some code ...

	// add extra items to myul
	myul(li('four'), li('five));

	// append myul into other element
	div(myul);

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

	(myul() instanceof DOMElement) === true

Comment type nodes:

	_comment('my comment');

CDATA type nodes

	_cdata('cdata text');

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:

	_var('var content');

## Tests

When installed for node with npm (do _make install_ first)

	$ make test

Tests with coverage report:

	$ make test-cov
<commit_msg>Documentation<commit_after># 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's best suited for small projects.

## Instalation

When using node:

	$ npm install domjs

_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 ?

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

		nav(
			ul({ 'class': 'breadcrumbs' },
				li(a({ href: '/' }, 'Home')),
				li(a({ href: '/section/'}, 'Section')),
				li(a('Subject'))));

		article(
			p('Lorem ipsum...'));

		footer('Footer stuff');
	};

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);

	var mydom = domjs(mytemplate);

### Other notes

You can save references to elements and operate on them later:

	var myul = ul(li('one'), li('two'), li('three'));

	// ... some code ...

	// add extra items to myul
	myul(li('four'), li('five));

	// append myul into other element
	div(myul);

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

	(myul() instanceof DOMElement) === true

Comment type nodes:

	_comment('my comment');

CDATA type nodes

	_cdata('cdata text');

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:

	_var('var content');

## Tests

Before running tests make sure you have node and npm installed and you've run
_make install_ first.

	$ make test

Tests with coverage report:

	$ make test-cov

{'fraction_non_alphanumeric': 0.11516314779270634, 'fraction_numerical': 0.0021935837674801205, 'mean_word_length': 3.923076923076923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1933410', 'n_tokens_mistral': 1159, 'n_tokens_neox': 1069, 'n_words': 459}