Skip to content
This repository was archived by the owner on Feb 19, 2022. It is now read-only.

Possibility to return undefined from template expression #80

@ghost

Description

I'm using rapscallion and am using helmet to render a title and meta description (see here):

        <div id="app">${appRenderer}</div>
          // ...
          // Set title and meta description
          ${() => {
            helmet = Helmet.renderStatic()
            return ''
          }}
          appendToHead('${() => helmet.title.toString()}')
          appendToHead('${() => helmet.meta.toString()}')

Now helmet needs to be instantiated after rendering the app, but since rapscallion throws an error when returning undefined from an expression* I'm just returning an empty string. This isn't really a big deal and the current solution works fine.

But, I thought it might be nice to allow expressions that evaluate to undefined, which would then just insert nothing. No idea if that's possible or even desirable, but it would allow me to omit the return ''.

*: throw new Error("Unknown value in template of type " + (typeof segment === "undefined" ? "undefined" : _typeof(segment)) + ": " + segment);

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