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

Helper Chaining #17

Open
Romanx opened this issue Sep 15, 2019 · 0 comments
Open

Helper Chaining #17

Romanx opened this issue Sep 15, 2019 · 0 comments
Labels
enhancement New feature or request under considation Being voted on to be implemented in a later version

Comments

@Romanx
Copy link
Contributor

Romanx commented Sep 15, 2019

Originally Requested by @Tasteful in #16

It could be useful to chain helper methods together before rendering. If we look at languages such as liquid we chain them together like {{ helper1 arg | helper2 }} with the results of helper1 going into the arguments of helper2.

Handlebars has a similar functionality with helpers by nesting the helper declarations like so: {{ helper1 (helper2 arg) }}

Currently this functionality can be simulated by nesting functions in your helper like so

var helpers = new Helpers()
    .Register<decimal>("FormatCurrencyAndQuote", (context, count) =>
    {
        return Quote(FormatCurrency(count))
    });

string FormatCurrency(decimal value) => count.ToString("C", new CultureInfo("en-GB"));
string Quote(string value) => $"\"{value}\"";

If you think this functionality would be useful please leave as 👍 or ❤️ and comment if you have a preference on synax

@Romanx Romanx added enhancement New feature or request under considation Being voted on to be implemented in a later version labels Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request under considation Being voted on to be implemented in a later version
Projects
None yet
Development

No branches or pull requests

1 participant