Git Product home page Git Product logo

ember-inflector's Introduction

Ember Inflector CI

Ember Inflector is a library for inflecting words between plural and singular forms. Ember Inflector aims to be compatible with ActiveSupport::Inflector from Ruby on Rails, including the ability to add your own inflections in your app.

Compatibility

  • Ember.js v3.16 or above
  • Ember CLI v2.13 or above
  • Node.js v10 or above

Installation

ember install ember-inflector

Usage

All methods are always available from the ember-inflector module:

import Inflector from 'ember-inflector';
import { singularize, pluralize } from 'ember-inflector';

Inflector.inflector.singularize("tacos"); // taco
Inflector.inflector.pluralize("taco"); // tacos

singularize("tacos"); // taco
pluralize("taco"); // tacos

pluralize(2, "taco"); // 2 tacos
pluralize(2, "tacos", { withoutCount: true }); // tacos

Custom Rules

If necessary you can setup special inflection rules for your application:

import Inflector from 'ember-inflector';

Inflector.inflector.irregular('person', 'people');
Inflector.inflector.uncountable('sheep');

Template Helpers

pluralize

Pluralize a word

{{pluralize "taco"}} -> tacos

Specify a count with the word, with the pluralization being based on the number of items.

{{pluralize 1 "taco"}} -> 1 taco
{{pluralize 2 "taco"}} -> 2 tacos

Specify a count with the word, with the pluralization being based on the number of items. Specify without-count=true to return on the word without the number.

{{pluralize 1 "taco" without-count=true}} -> taco
{{pluralize 2 "taco" without-count=true}} -> tacos

singularize

{{singularize 'octopi'}} -> octopus

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

ember-inflector's People

Contributors

blimmer avatar bradleypriest avatar chriskrycho avatar cibernox avatar dependabot-preview[bot] avatar dependabot[bot] avatar ember-tomster avatar fivetanley avatar fsmanuel avatar ghempton avatar glaukommatos avatar gnclmorais avatar heroiceric avatar igort avatar jcope2013 avatar jerel avatar jrjohnson avatar karlguillotte avatar locks avatar makepanic avatar mmun avatar mydea avatar olivia avatar rwjblue avatar sandstrom avatar sergeastapov avatar stefanpenner avatar tricknotes avatar turbo87 avatar victornamuso avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.