Skip to main content

When picking an option to render something it would be convenient to have an option “snippet returns false” in addition to the option of “snippet returns true.”


My use case:


I have two buttons. One says “show preferred records only”, which queries a model to show user specific preferred records, and another that says “show all records” which queries a model and ignores the model condition for user preferred records. I only want to show one button at a time. When the preferred records are displayed, I show “show all records” and when all records are displayed, I show the button “show preferred records only.” In order to do that, I had to write two snippets, which do the same exact thing, except one returns the complement value of the other.


If I had an option of “snippet returns false” I’d be able to get away with one snippet!

Shmuel,

Can you just have your snippet check the value of whatever field you’re using to conditionally render your buttons to decide if it should include the condition or not?


Ah, nevermind…

But I think in your use case you could just create a ui-only checkbox to turn on/off and use that for your rendering condition. That would allow you to have one snippet, if I’m understanding correctly.


That’s what I ended up doing, thanks! I try to keep the number of components/fields small since it’s not possible to document it in the page (and I can document JavaScript).