djotaku,
@djotaku@mastodon.social avatar

@mkennedy you've mentioned a few times you prefer chameleon to jinja2. What's the benefit in your opinion? Also, what about partials love when using htmx?

mkennedy,
@mkennedy@fosstodon.org avatar

@djotaku As for partials, wow, do they lead to readable & reusable HTML. Check out these few lines of HTML: https://github.com/mikeckennedy/jinja_partials/blob/main/example/templates/home/listing.html That is ALL of the html for this page:

djotaku,
@djotaku@mastodon.social avatar

@mkennedy thanks for your examples. The difference is subtle, but I think I see what you are saying. I had a typo in my second question. I meant to ask- can you still do partials with chameleon or does it have some other feature that makes htmx work?

mkennedy,
@mkennedy@fosstodon.org avatar

@djotaku You can still do partials with Chameleon, https://github.com/mikeckennedy/chameleon_partials :)

The very clear difference is you can write arbitrary Python code in Jinja. That should never be done but it is encouraged.

Chameleon only allows a very small subset: string output, if statements, and loops. That’s it. So you are required to write better Python code. I think ironically this is why it’s less popular. :)

mkennedy,
@mkennedy@fosstodon.org avatar

@djotaku
@djotaku These really almost deserve a blog post, but they’ll have to suffice in two separate responses here :)

mkennedy,
@mkennedy@fosstodon.org avatar

@djotaku Templates. Compare how much python gets mixed into the HTML here? This is both very cluttered, error prone, encourages writing more python here where it absolutely does not belong, and it’s not valid HTML.

Jinja:

mkennedy,
@mkennedy@fosstodon.org avatar

@djotaku Contrast that with pure, valid HTML. No tempting of writing Python in HTML, and clean and tidy:

Chameleon:

mkennedy,
@mkennedy@fosstodon.org avatar

@djotaku It’s night and day to me. Jinja is a very poor language if you care about separations of concern, sharing html with non-python devs (e.g. designer), etc. To be somewhat fair, almost all other template languages are like Jinja, not Chameleon.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • kavyap
  • thenastyranch
  • ethstaker
  • InstantRegret
  • osvaldo12
  • DreamBathrooms
  • Durango
  • magazineikmin
  • khanakhh
  • Youngstown
  • everett
  • slotface
  • rosin
  • mdbf
  • provamag3
  • ngwrru68w68
  • tacticalgear
  • cubers
  • GTA5RPClips
  • modclub
  • Leos
  • tester
  • megavids
  • cisconetworking
  • normalnudes
  • anitta
  • JUstTest
  • lostlight
  • All magazines