Skip to content

Support for returning a complex object from a subexpression #264

Description

@rmja

Hi,

In handlebars.js one can create a helper that returns a complex object to be used by other helpers like so:

Handlebars.registerHelper("now", () => {
    return new Date(); // Returns a complex object, not a string
});
Handlebars.registerHelper("format", (value) => {
    if (value instanceof Date) {
        // This is the complex Date object, format as date
        return Handlebars.SafeString(value.valueOf());
    else {
        // This is not a Date object
        return Handlebars.SafeString("not a date");
     }
});

In the template I have something like {{format (now)}}. This works in handlebars.js, but I cannot figure out how to do it in .NET land. I don't want to write (serialize) the object in now() and then deserialize it again in format().

Any suggestions?

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions