firenze-behavior-slug
Slug behavior for firenze.js.
Automatically generate slugs (SEO friendly strings) when creating new records.
$ npm install --save firenze-behavior-slug
$ bower install --save firenze-behavior-slug
Contents
What it does
When saving a new model, it will automatically generate a slug and set it to specified field for you.
For example, when saving a post with the title Hello World
:
var posts = ;var post = posts; post;
It will also save the value hello-world
in slug
field.
Usage
Node.js
With npm:
$ npm install --save firenze-behavior-slug
Now you can require it as follows:
var SlugBehavior = ; // create your Database instance... db;
If you want to pass extra configuration options:
db;
Browser
Or Bower:
$ bower installl --save firenze-behavior-slug
Can be loaded in your HTML page as follows:
<script src="bower_components/lodash/lodash.min.js"></script><script src="bower_components/async/lib/async.js"></script><script src="bower_components/bluebird/js/browser/bluebird.min.js"></script><script src="bower_components/validator-js/validator.min.js"></script> <script src="bower_components/firenze/dist/firenze.min.js"></script><script src="bower_components/firenze-behavior-slug/dist/firenze-behavior-slug.min.js"></script> <script> // Slug behavior is available in `firenze.SlugBehavior`</script>
Testing
Tests are written with mocha, and can be run via npm:
$ npm test
License
MIT © Fahad Ibnay Heylaal