What is the preferred Lift method for handling conditional content in a template?
As a concrete example, let's introduce the general design of the Add to My List button. If you are not in your favorites, click the button to add it. If you are already in your favorites, there is a button to delete it. Something like that:
<div class="lift:MySnippet"> <div class="favorite"> <form id="doFavorite" class="lift:MySnippet.favorite?form=post"> <input type="submit" value="Add to Favorites" /> </form> <form id="doUnfavorite" class="lift:MySnippet.unfavorite?form=post"> <input type="submit" value="Remove from favorites" /> </form> </div> </div>
I donโt see an obvious way in the fragment (via CSS bindings or transformers) to conditionally save one form against another based on the corresponding โfavorableโ state.
Based on the Java / SpringMVC / JSP background, this would be solved with a simple <c:choose> statement, but with as much time as I spent trying to figure it out, I can only assume that I am going to do this all the way back. ..
Thanks in advance to guru lifting!
source share