mirror of
https://github.com/Oreolek/raconteur.git
synced 2024-05-02 00:49:20 +03:00
Merge branch 'master' into stable
This commit is contained in:
commit
91a6ffa4ae
|
@ -45,7 +45,7 @@ Raconteur is still in active development towards its 1.0 release.
|
|||
|
||||
Raconteur can be added as a dependency to a package.json file and installed from git. Or, you can use the [scaffold](http://github.com/sequitur/raconteur-scaffold).
|
||||
|
||||
Raconteur itself doesn't contain any command-line tools or anything that needs to be installed globally. You just need `npm` and `gulp` to be working on your system.
|
||||
Raconteur itself doesn't contain any command-line tools or anything that needs to be installed globally. You just need `npm` to be working on your system. Raconteur is a set of CommonJS modules designed to work with Browserify and a build system like Grunt or Gulp.
|
||||
|
||||
## Code examples
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
var situation = require('raconteur/situation.js'),
|
||||
$ = require('jquery'),
|
||||
undum = require('undum-commonjs'),
|
||||
oneOf = require('raconteur/oneOf.js'),
|
||||
elements = require('raconteur/elements.js'),
|
||||
qualities = require('raconteur/qualities.js');
|
||||
|
||||
situation.exportUndum();
|
||||
|
||||
var a = elements.a,
|
||||
span = elements.span;
|
||||
|
||||
|
|
|
@ -8,19 +8,28 @@ Since Raconteur began its life as a library for writing Undum stories using Coff
|
|||
|
||||
## A Note on the Undum API and CommonJS
|
||||
|
||||
Raconteur uses a modified version of Undum that complies with CommonJS practices: undum-commonjs. What this means is that, instead of exporting an API directly, Undum now works like a [Node.js] module. In practice, what this means is that instead of the global `undum` object that you had in vanilla undum, you now have to explicitly `require` it. Similarly, we are now using a CommonJS version of JQuery instead of loading JQuery separately in our html file:
|
||||
Ideally, Raconteur is supposed to use a commonjs-compliant version of Undum that can be instantiated with `require()´. In actuality, pending a rewrite of Undum's codebase, Raconteur and Undum rely on a single, global Undum object. For this reason, currently the interface to import Undum in your project is:
|
||||
|
||||
```coffeescript
|
||||
undum = require('undum-commonjs')
|
||||
$ = require('jquery')
|
||||
situation = require('raconteur/lib/situation.js')
|
||||
situation.exportUndum()
|
||||
```
|
||||
|
||||
```javascript
|
||||
var undum = require('undum-commonjs'),
|
||||
$ = require('jquery');
|
||||
var situation = require('raconteur/lib/situation.js');
|
||||
situation.exportUndum();
|
||||
```
|
||||
|
||||
Using `$` as the name of the JQuery object is a convention and not mandatory. Similarly, `undum` can be anything.
|
||||
This will ensure that there is a global Undum object and that it is the same as Raconteur's. This is a hack; expect this API to change... eventually.
|
||||
|
||||
JQuery is also used as a CommonJS module, so if you intend to call JQuery directly in your story, you'll need to require it:
|
||||
|
||||
```coffeescript
|
||||
$ = require('jquery');
|
||||
```
|
||||
```javascript
|
||||
var $ = require('jquery');
|
||||
```
|
||||
|
||||
## Raconteur Modules
|
||||
|
||||
|
|
Loading…
Reference in a new issue