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 <else /> support for bindJson #128

Open
srid opened this issue May 16, 2021 · 0 comments
Open

Add <else /> support for bindJson #128

srid opened this issue May 16, 2021 · 0 comments

Comments

@srid
Copy link
Contributor

srid commented May 16, 2021

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.

srid added a commit to srid/emanote that referenced this issue May 16, 2021
The 'tags' feature in template is broken. cf. snapframework/heist#128

One way to address it is to specify a frontmatter.yaml default for Aeson.Value, to ensure that all fields are present regardless of what's in the individual Markdown file.
srid added a commit to srid/emanote that referenced this issue May 17, 2021
The 'tags' feature in template is broken. cf. snapframework/heist#128

One way to address it is to specify a frontmatter.yaml default for Aeson.Value, to ensure that all fields are present regardless of what's in the individual Markdown file.
shivaraj-bh pushed a commit to shivaraj-bh/emanote that referenced this issue Dec 18, 2023
The 'tags' feature in template is broken. cf. snapframework/heist#128

One way to address it is to specify a frontmatter.yaml default for Aeson.Value, to ensure that all fields are present regardless of what's in the individual Markdown file.
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

1 participant