🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

tbone

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tbone

A simple library to generate valid HTML and normalizing markup

Source
npmnpm
Version
0.0.3f
Version published
Weekly downloads
11
266.67%
Maintainers
1
Weekly downloads
 
Created
Source

tbone

TBone is an small JavaScript library for generating valid HTML. It is based on an article by Jason Grosman, "Behind the Code: Avoiding Spaghetti".

It is designed to work in NodeJS, Mongo's shell (via mongo-modules).

Examples

NodeJS/Mongo Shell example

	var tbone = require("tbone");

	// Displaying an HTML 5 valid HTML page.
	console.log(tbone.htmlDoc(
		tbone.html(
			tbone.head(
				tbone.title("Hello World")
			),
			tbone.body(
				tbone.h1("Hello World")
			)
		)
	).toString());

Folding in CSS/JS with concatination

tbone proviles a limited facility to concatinate CSS or JavaScript files. it would then render it in-line or write out a file and include it back via a relative link with the .as().

	var tbone = require("tbone");

	tbone.CSS.import("css/reset.js");
	tbone.CSS.import("css/responsive.js");
	tbone.CSS.import("css/ie-fixes.js");

	tbone.JS.import("js/jquery-1.8.0.min.js");
	tbone.JS.import("js/the-app.js");
	
	// Displaying an HTML 5 valid HTML page.
	console.log(tbone.htmlDoc(
		tbone.html(
			tbone.head(
				tbone.title("Hello World"),
				tbone.CSS.inline()
			),
			tbone.body(
				tbone.h1("Hello World"),
				tbone.JS.as("js/combined.js")	
			)
		)
	).toString());

Generating self contained widgets with CSS and HTML fragments.

	var tbone = require("tbone");

	tbone.CSS.import("css/reset.js");
	tbone.CSS.import("css/responsive.js");
	tbone.CSS.import("css/ie-fixes.js");

	tbone.JS.import("js/jquery-1.8.0.min.js");
	tbone.JS.import("js/the-app.js");
	
	// Displaying an HTML 5 friendly div with CSS
	// writting in-line and JS combined at bottom of div.
	console.log(tbone.widget(
			tbone.div(
				tbone.h1("Hello World"),
			),
		tbone.CSS.inline(),
		tbone.JS.as("js/combined.js")	
		)
	).toString());

FAQs

Package last updated on 26 Sep 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts