Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

Handlebars : CheckIf with multiple conditions / operator

  • #10594
    Avatar photo[anonymous]

    is it possible to do something like this?

    {{#each tags}}
    {{#checkIf id '!=' 1 || id '!=' 2 || id '!=' 3}}
    {{name}}
    {{/checkIf}}                     
    {{/each}}
    #10595
    Avatar photo[anonymous]

    Hi,

    Currently it is not possible, but we will add in upcoming Publii v.0.43 two new features:

    – contains and notContains operator for checkIf:

    {{#checkIf id ‘notContains’ [1,2,3]}}

    – new handlebars helper – notContains:

    {{#notContains id “1,2,3”}}

    #10604
    Avatar photo[anonymous]

    Oh, cool! This could be a really good thing!

    thanks for the feedback 🙂
    Do you have any idea when this is planned?

    #10605
    Avatar photo[anonymous]

    We will release Publii v.0.43 in nearest 1-2 weeks

    #10606
    Avatar photo[anonymous]

    Many Thanks !

    #10641
    Avatar photo[anonymous]
    Tomasz Dziuda wrote:

    Hi,

    Currently it is not possible, but we will add in upcoming Publii v.0.43 two new features:

    – contains and notContains operator for checkIf:

    {{#checkIf id ‘notContains’ [1,2,3]}}

    – new handlebars helper – notContains:

    {{#notContains id “1,2,3”}}

    How many conditions will we be able to meet with this new version? Only 3? or as many as we want? thank you

    #10642
    Avatar photo[anonymous]

    You can put as many values as you need 🙂

    The updated Publii files will be available at todays evening – official release info will be published after the weekend, so if you need this feature as soon as possible check out our download page at evening 🙂

    #10643
    Avatar photo[anonymous]

    Even better!

    it’s not urgent but I love testing new things! So I will!

    Thanks again for the feedback.

    PS: I’d like to use this with the source theme but I’ve discovered a bug in the theme (to filter tags) that I don’t know how to fix (see ticket: #25135)

    #11502
    Avatar photo[anonymous]
    Tomasz Dziuda wrote:

    {{#checkIf id ‘notContains’ [1,2,3]}}

    Hello Tomasz,
    Have you implemented these helpers yet?
    I don’t see them in the documentation?

    Thank you

    #11503
    Avatar photo[anonymous]

    And because I have this error :

    Rendering process failed
    An error (1002) occurred during parsing index.hbs file.

    Missing helper: “notContains”

    {{#each tags}}
                         {{#notContains id '1,2,3'}}
                            {{name}}
                            {{/notContains}}
                         {{/each}}