An open API service indexing awesome lists of open source software.

https://github.com/fooker/constructjs

Library for creating arbitrary JavaScript structures and JSON from templates
https://github.com/fooker/constructjs

Last synced: 2 months ago
JSON representation

Library for creating arbitrary JavaScript structures and JSON from templates

Awesome Lists containing this project

README

        

General Information
===================

construct.js is a JSON prototyping system for coffeescript/javascript. It allows
to generate arbitrary JSON structures from a templat.

construct.js allows to intermix JSON structures with logical elements using
functions. If the template is evaluated, all functions contained in the template
are called and the function is replaced by its return value.

Additionaly construct.js provides a set of usefull helper functions which can be
used in the templates.

Installation
============

Include the file js/construct.js in your application.

Usage
=====

You can use the cs command to create a construct.js template. The structure
passed to the cs command is used as the template:

tpl = cs {
'foo' : 42
'bar' : () -> 23
}

The template can be transaformed into a real structure by calling the cs object:

tpl = cs {
'bar' : () -> 23
}

result = tpl()
# result now contains the evaluated structure: { 'bar' : 23 }

The helper functions allows to put some logic into the template:

tpl = cs {
'bar' : cs.if (() -> true), {
'foo' : 23
}, {
'bar' : 42
}

result = tpl()
# result now contains the evaluated structure: { 'foo' : 23 }

How to report bugs
==================

Bugs should reported to the author at or using the
bug-tracker at https://github.com/fooker/constructjs/issues.

In the bug report please include:

* Information about your system. For instance:

- What operating system and version
- What version of Apache / LightTPD
- What version of python

And anything else you think is relevant.

* How to reproduce the bug.

Please include a short test that exhibits the behavior. As a last resort, you
can also provide a pointer to a larger installation that can be
downloaded.

* If the bug was a crash, the exact text that was printed out when the
crash occured.

* Further information such as stack traces may be useful, but is not
necessary.

Patches
=======

Patches should also be submitted the author at or
using git pull requests using https://github.com/. If the patch fixes an
existing bug, add the patch as an attachment to that bug report.

Otherwise, enter a new bug report that describes the patch, and attach
the patch to that bug report.

Patches should be in unified diff form. (The -up option to GNU diff.)