Skip to content

Add custom lists to configure that can be articlized and pluralized #16

Description

@rmtuckerphx

Type: FEATURE REQUEST

Challenge:
Imagine a UI that builds templates and lists and then executes them dynamically. Adding those lists as actions is not currently possible.

Solution:
Allow configure to accept custom lists. Besides a key and values, you can specify whether to support articlize and pluralize:

var Sentencer = require('sentencer');

Sentencer.configure({
    // the list of nouns to use. Sentencer provides its own if you don't have one!
    nounList: [],

    // the list of adjectives to use. Again, Sentencer comes with one!
    adjectiveList: [],

    customLists: [
        {
            key: "animal",
            values: ["dog", "cat", "horse", "pig", "elephant"],
            articlize: "an_animal", // if named, add action that calls articlize
            pluralize: "animals"    // if named, add action that calls pluralize
        },
        {
            key: "band",
            values: ["The Beatles", "The Who", "Styx"],
            articlize: "",  // no key or empty value, don't articlize
            pluralize: ""   // no key or empty value, don't pluralize
        }
    ],

    // additional actions for the template engine to use.
    // you can also redefine the preset actions here if you need to.
    // See the "Add your own actions" section below.
    actions: {
        my_action: function () {
            return "something";
        }
    }
});

The templates available for custom lists:

"{{ animal }}"
// "dog", "cat", "horse", "pig", "elephant"

"{{ an_animal }}"
// "a dog", "a cat", "a horse", "a pig", "an elephant"

"{{ animals }}"
// "dogs", "cats", "horses", "pigs", "elephants"


"{{ band }}"
// "The Beatles", "The Who", "Styx"

"{{ a_band }}"
// ignore

"{{ bands }}"
// ignore

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions