Web Development,
JavaScript, jQuery,
HTML and CSS stuff.

rSupplant

JSON to HTML Recursive Templating

Download the code

Documentation

rSupplant( data, setup, extraParams )

data: Array of Objects (JSON)

setup: Object

extraParams: To pass within each callback if needed. Optional.

Setup:

template: Object

Recursive definition of the html template in two separate properties. You use placeholders anywhere in your templates.

outerContent: String

innerContent: String

Placeholder <outerContent> is needed to create the recursive definition.

Placeholders can be any of your data object property names. It will map directly with it. You can define your own placeholders wich will need to be define as a function (see placeholders)

placeholders: Object

Callbacks for any placeholders define in the template. The property names are directly map to the placeholders. Useful when some processing are needed before replacing the placeholder with the corresponding data.

recursiveProperty: String, (default: 'list')

The property name of your data structure that makes it recursive. Only necessary when recursion does apply.

All code and content by Philippe Rathé is licensed under a Creative Commons Attribution 2.5 Canada License (unless otherwise mentioned).
Creative Commons License