I've been sitting on this for a while and finally pushed it out, having never really had the chance to give the idea the work it deserves. Anyway, the idea is simple: templates are a mess. They have goofy language variants, etc. Your editor can't color them. Why not just use code to generate the HTML? Still needs: Context-sensitive escaping, css generation, javascript inclusion.
Idea: using code rather than templates to generate HTML
11–20 of 74 posts
Re: Idea: using code rather than templates to generate HTML
#12Re: Idea: using code rather than templates to generate HTML
#13I've been sitting on this for a while and finally pushed it out, having never really had the chance to give the idea the work it deserves. Anyway, the idea is simple: templates are a mess. They have goofy language variants, etc. Your editor can't color them. Why not just use code to generate the HTML? Still needs: Context-sensitive escaping, css generation, javascript inclusion.
First it's overkill. The reason we have a www at all is because HTML and its variants are dead simple. If the client decides that six key sentences should be yellow and emphasized, I go into my template and add a Yellow text! to my template.
Using your generator, I now have to figure out a whole new way of doing that.
The second point follows: Any first year web monkey can learn to add spans and em's. It takes a bit more effort to understand python. While this might not matter to someone who understands both, it offers much less flexibility to the already available alternative.
Django's template implementation is very, very good. It fits quite well into your average web shop and even fails silently.
I like your desire to scratch your own itch, but I felt I should answer your question.
Re: Idea: using code rather than templates to generate HTML
#14Though, at least looking at the Python implementation it seems very clean and simple compared to others I've seen (though you're importing pprint twice), but then again I'm pretty opposed to the idea in the first place so I haven't really browsed the available options.
Re: Idea: using code rather than templates to generate HTML
#15I've been sitting on this for a while and finally pushed it out, having never really had the chance to give the idea the work it deserves. Anyway, the idea is simple: templates are a mess. They have goofy language variants, etc. Your editor can't color them. Why not just use code to generate the HTML? Still needs: Context-sensitive escaping, css generation, javascript inclusion.
The reason why not is that eventually you will want to hand the site to a designer and not have to do a half-hour of work on it every coupla weeks for the rest of its life. Making things easier for the designer reduces your total work; forcing the designer to work inside the HTML your tool produces will either limit the nifty things she can do, or require you to come back and touch this code again and again. Even the…
Developers should write HTML for the same reason that business people should learn to edit HTML--it's the best canonical format for all stakeholders.
Re: Idea: using code rather than templates to generate HTML
#16Re: Idea: using code rather than templates to generate HTML
#17I've been sitting on this for a while and finally pushed it out, having never really had the chance to give the idea the work it deserves. Anyway, the idea is simple: templates are a mess. They have goofy language variants, etc. Your editor can't color them. Why not just use code to generate the HTML? Still needs: Context-sensitive escaping, css generation, javascript inclusion.
I don't want too sound negative, but there are a number of reasons this is a less than feasible idea. First it's overkill. The reason we have a www at all is because HTML and its variants are dead simple. If the client decides that six key sentences should be yellow and emphasized, I go into my template and add a Yellow text! to my template. Using your generator, I now have to figure out a whole new way of doing that…
Re: Idea: using code rather than templates to generate HTML
#18Seaside ( http://seaside.st/ ) does this. And the approach taken to an extreme works very well. It supports components with states with example.
"I am Avi Bryant, your argument is invalid."
Re: Idea: using code rather than templates to generate HTML
#19Earlier quoted context omitted.
I don't want too sound negative, but there are a number of reasons this is a less than feasible idea. First it's overkill. The reason we have a www at all is because HTML and its variants are dead simple. If the client decides that six key sentences should be yellow and emphasized, I go into my template and add a Yellow text! to my template. Using your generator, I now have to figure out a whole new way of doing that…
If you ever name a class yellow, you've entirely missed the point of CSS.
Re: Idea: using code rather than templates to generate HTML
#20Earlier quoted context omitted.
I don't want too sound negative, but there are a number of reasons this is a less than feasible idea. First it's overkill. The reason we have a www at all is because HTML and its variants are dead simple. If the client decides that six key sentences should be yellow and emphasized, I go into my template and add a Yellow text! to my template. Using your generator, I now have to figure out a whole new way of doing that…
If you ever name a class yellow, you've entirely missed the point of CSS.