Login

Tag "logic-doesnt-belong-in-templates"

Snippet List

Switch/case tags.

Meant mostly as a demo of how to do complex block tags, here's a switch/case implementation. It's deliberately simplistic: no default cases, no multiple values for the same case, etc. This is so that you can focus on the technique. Pay particular attention to how both switch and case pull out their child nodes and save them for later rendering. This is a very useful technique for these types of "structured" template tags.

  • templatetag
  • switch
  • case
  • flow
  • logic-doesnt-belong-in-templates
Read More

1 snippet posted so far.