News for hackers. Stuff that matters.
Re:Zed Shaw: Tir Web Framework Officially Up by meric on Friday December 03, 2010 @10:54PM (#1968438)
Last time this was posted I was really interested in it. So interested in fact, I built a django-style template library to go with it because I really liked 'extends' and 'block'.

Github https://github.com/meric/tier/

Example https://github.com/meric/tier/blob/master/main.lua http://pastehtml.com/view/1c26ovp.html

Zed would think this is contradicting the point of Tir, though; it being a micro-framework. =\

Re:Zed Shaw: Tir Web Framework Officially Up by zedshaw on Friday December 03, 2010 @11:01PM (#1968453)
Interesting, I'll take a look at this some more. My only question is, isn't plain old Lua already like django's templates. What specifically are you adding that embedded lua doesn't just give you?
Re:Zed Shaw: Tir Web Framework Officially Up by meric on Friday December 03, 2010 @11:18PM (#1968494)
Template inheritance. See http://docs.djangoproject.com/en/dev/topics/templates/#id1

  `Template inheritance¶
  The most powerful -- and thus the most complex -- part of 
  Django's template engine is template inheritance. Template 
  inheritance allows you to build a base "skeleton" template 
  that contains all the common elements of your site and 
  defines blocks that child templates can override.`
Having made it in lua myself, I can tell you it is indeed quite complex. ;)

The lua template only has "include" (i.e. copying another template into this template), but not "extends", (i.e. use another template as a skeleton and this template only provides details on how to fill it).

Re:Zed Shaw: Tir Web Framework Officially Up by zedshaw on Saturday December 04, 2010 @02:13AM (#1968775)
Well, I only did what I needed, but since Lua's included code blocks are also functional, wouldn't it be easier to just allow passing arguments? It'd also make a lot more sense. I find Django/Jinja inheritance concepts really confusing.

I'll take a look at the code and see what I can come up with.

Re:Zed Shaw: Tir Web Framework Officially Up by meric on Saturday December 04, 2010 @05:10AM (#1968960)
If you wanted, say, your about page to have an extra image next to the logo (as an exception to all the other pages), then you'd have to rewrite another header file to include, whereas if you used template inheritance you could just override that logo part without having another almost identical header file.

It may be confusing if you're new to it... but so are OOP, Lambda calculus, and others. ;)

EDIT: The code isn't that clean... Apologies in advance.

Re:Zed Shaw: Tir Web Framework Officially Up by grandalf on Saturday December 04, 2010 @01:00AM (#1968654)
this is awesome, feel like writing it for ruby too?
Re:Zed Shaw: Tir Web Framework Officially Up by start_something on Saturday December 04, 2010 @01:42PM (#1969839)
Check out DRYML from the Hobo project (hobocentral.net). You build taglibs that can be used and overridden however you like.
Re:Zed Shaw: Tir Web Framework Officially Up by meric on Saturday December 04, 2010 @01:12AM (#1968672)
I don't know ruby... but RoR is an established platform, I would think it would have something similar?
Re:Zed Shaw: Tir Web Framework Officially Up by grandalf on Saturday December 04, 2010 @03:46AM (#1968881)
Not with the same notion of inheritance that django templates have (with multiple blocks that can be overridden in child classes). There is one project someone attempted but never finished.
Re:Zed Shaw: Tir Web Framework Officially Up by btucker on Saturday December 04, 2010 @11:26AM (#1969517)
Isn't this just content_for/yield(:sym)? Or are you talking about something else? http://api.rubyonrails.org/classes/ActionView/Helpers/Captur...
Re:Zed Shaw: Tir Web Framework Officially Up by grandalf on Saturday December 04, 2010 @05:53PM (#1970388)
That's close. Nowhere near as elegant as Django templates though, in my opinion.