You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.
I'm not sure if this is really a bug. I've tested it with the {@getTags} and the {@getAuthors} Helper and both worked as expected. I've put this in my blog.dust:
{@getTags slug="not-existing-tag"}
{#tags}
{name}
{:else}
No tags
{/tags}
{/getTags}
and got the output: No Tags in the rendered page.
Maybe this issue is a result of ending up in the catch-block as described here?
I'll have to investigate this further then. I was pretty sure you have to explicitly call the else block. In this case, models.user.findAll won't throw an error if no results are found — it will just result in an empty array.
Sorry, it's been awhile since I've worked with Dust.js. Unfortunately, it may have been a bad choice longterm since the lib seems to be deprecated by LinkedIn. In hindsight, Nunjucks may have been a better choice. 😕
I created some dust-Files (blog.dust + post.dust) and implemented all of the above named helpers. They all worked like expected - when used in the right context ;)
So, the {:else}-Block is not working in the following cases:
the helper function ends up in the .catch-block because of some error in SQL
the helper is used in the wrong context (eg. {@getRelatedPosts} in {#author}-Context)
I think this is acceptable an this issue can be closed.
As discovered in #104, some helpers do not support the
{:else}
block as documented. This is a relatively easy fix for anyone looking to contribute. 👋The
{:else}
block is an optional block in some helpers that will render when a helper fails to find any suitable results. For example:In code, the correct way to implement
{:else}
looks something like this:Theme Helpers
The following helpers are documented to support the
{:else}
block but currently do not.The text was updated successfully, but these errors were encountered: