Socket
Socket
Sign inDemoInstall

modella-slug

Package Overview
Dependencies
0
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    modella-slug

create slugs for models


Version published
Weekly downloads
15
increased by650%
Maintainers
2
Install size
7.08 kB
Created
Weekly downloads
 

Readme

Source

model-slug

create slugs for models

Installation

In the browser (with component):

component install modella/slug

On the server (with node.js):

npm install modella-slug

Example

var slug = require('slug');

var Blog = modella('blog')
  .attr('title')
  .attr('content')
  .use(slug('title'))

  var b = new Blog();
  b.title('A seriously interesting title');
  b.slug();
  // => 'a-seriously-interesting-title'

Multi-Attribute Example

var slug = require('slug');

var Blog = modella('blog')
  .attr('title')
  .attr('author')
  .attr('content')
  .use(slug(['title', 'author'], ':title-by-:author'));

  var b = new Blog();
  b.title('Some blog post');
  b.slug();
  // => 'some-blog-post-by-'

  b.author('Ryan S.');
  b.slug();
  // => 'some-blog-post-by-ryan-s'

Function Based Example

var slug = require('slug');


var Blog = modella('blog')
  .attr('title')
  .attr('author')
  .attr('content');

var getBlogSlug = function(blog) {
  var result = blog.title();
  if(blog.author()) {
    result += ' by ' + blog.author();
  }
  return result;
};

  Blog.use(slug(['author', 'title'], getBlogSlug));

  var b = new Blog();
  b.title('Some blog post');

  b.slug();
  // => 'some-blog-post'

  b.author('Ryan S.');
  b.slug();
  // => 'some-blog-post-by-ryan-s'

License

MIT

Keywords

FAQs

Last updated on 21 Feb 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc