Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rmtuckerphx opened this issue Apr 19, 2020 · 1 comment
Open

Comments

@rmtuckerphx
Copy link

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
rmtuckerphx added a commit to rmtuckerphx/Sentencer that referenced this issue Apr 21, 2020
rmtuckerphx added a commit to rmtuckerphx/Sentencer that referenced this issue Apr 21, 2020
@plant7403
Copy link

It's awesome! But it's still not merged? 🥲

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants