I think this should be an optional package that just has a well documented interface so people can use, or re-implement as needed.
I was thinking a file called renderer.js which provides an interface you can use like:
// Returns an Underscore like template function
UniversalForms.Renderer.getTemplate();
// Renders the template
UniversalForms.Renderer.render(options);
// Use decorator pattern to add methods to object prototype
for (var prop in UniversalForms.Renderer) {
Field.prototype[prop] = UniversalForms.Renderer[prop];
Form.prototype[prop] = UniversalForms.Renderer[prop];
}
// Usage
var f = new Form();
$('body').append(f.render());
I think this should be an optional package that just has a well documented interface so people can use, or re-implement as needed.
I was thinking a file called
renderer.js
which provides an interface you can use like: