janus-stdlib
v0.5.3
Published
The reference set of code components and build tools for Janus
Downloads
91
Readme
Janus Standard Library
The Janus Standard Library is a collection of useful View
s and Varying
helpers that reflect one opinionated way of building an application on top of Janus. Probably the most useful thing it does is provide generic, generally applicable default views for all the default Attribute
class types, as well as List
, in both default
and edit
contexts.
It depends on the presence of a DOM manipulation library largely compatible with the jQuery API: jQuery, Zepto, (and Cheerio? [TBD]) are all supported targets.
Usage
To start, require the npm package: janus-stdlib
.
You can register the entire library wholesale (recommended): require('janus-stdlib').view.registerWith(myLibrary)
.
Or, you can pick and choose what you wish to register; for instance: view.registerWith(myLibrary) for view in require('janus-stdlib').view when view not in [ 'literal', 'varying' ]
.
As noted above, there needs to be a jQuery-compatible library available. Currently, we default to using a combination of domino
and jQuery
for server-side rendering and unit testing (this may be replaced by Cheerio
at some point in the future), and we require a local reference to janus-dollar
to understand which DOM manipulation library you are using.
Development
Should be standard and straightforward: clone the repository, and make
should set everything up assuming you have npm
and node
installed already. You can also make test
to run the unit tests, or make test-coverage
to run the unit tests and generate a code coverage report.
Contributing
Pull requests are welcome. If you wish to contribute, please bear in mind:
- This is meant to be a relatively opinion-free standard library. Functionality that is too specific or pulls in particular dependencies are likely to be rejected.
- Please do run the unit tests (
make test
) and create new ones where relevant. - Remember to write code in the philosophy of Janus. Avoid mutable state wherever possible, and leverage the
Varying
monad for as much business logic and state management as you can.
License
The Janus Standard Library is licensed under the WTFPL.