Skip to content

Add <else /> support for bindJson #128

Open
@srid

Description

I'm parsing YAML into a Aeson.Value and passing it straight to the template using bindJson, for using like this (tags would be a YAML field with list value):

            <with var="tags">
              <a title="Tag" class="px-1 bg-gray-100 rounded">
                <value />
              </a>
            </with>

This however doesn't work when the YAML has no fields named "tag"; Heist throws: expression error: can't find "tags" in JSON object (<with> tag)

I'd like to be able to specify a "else" case to render if there is no such field, based on the similar behaviour if the IfElse splice, i.e.

            <with var="tags">
              <a title="Tag" class="px-1 bg-gray-100 rounded">
                <value />
              </a>
              <else />
              <p>This note is not tagged</p>  <!-- Can also be empty -->
            </with>

What do you folks think of this feature? It may be extended to <value> and <snippet> as well.

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