tag:blogger.com,1999:blog-4477131926658044957.post4398893616175764487..comments2023-05-28T03:47:58.240-07:00Comments on pydanny: Stupid Template Languagespydannyhttp://www.blogger.com/profile/00481523876497446983noreply@blogger.comBlogger20125tag:blogger.com,1999:blog-4477131926658044957.post-18557398146161155602011-03-08T08:05:34.668-08:002011-03-08T08:05:34.668-08:00Not all logic is business logic. There is template...Not all logic is business logic. There is template logic too. Take the simple example, if user is logged in put personalized greeting here, or the color scheme of user's choice.<br /><br />Template logic gets more complicated from there the more complex your app is. You need a full language to express these things, otherwise you just move things from your views to your controllers. That's just as bad as the other way around!<br /><br />Too stupid template languages forces you to do that.Jonas B.noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-11384837875539639222010-12-06T12:08:23.054-08:002010-12-06T12:08:23.054-08:00Hi, You can also look at C# incarnation of TAL in ...Hi, You can also look at C# incarnation of TAL in project SharpTAL: http://sharptal.codeplex.com (which was ported from python implementation - project SimpleTAL). I added sme interesting extension to METAL such as macro paameters and macro imports. Some ideas could be implemenmted in my favourite python template engine Chameleon :)<br /><br />Regards<br />-Romanrlackohttps://www.blogger.com/profile/14665687629932573433noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-3915342406550091882010-12-06T11:12:22.698-08:002010-12-06T11:12:22.698-08:00@temoto - Are you saying that stupid must mean fas...@temoto - Are you saying that stupid must mean fast and DTL is slow? And that is a big failure of DTL?<br /><br />The speed of your template language is generally a small issue when it comes to performance problems and is normally the last thing you need to worry about. Which is why this article is so amusing! http://www.codeirony.com/?p=9<br /><br />In a nutshell, before you care about template performance, take a look at business logic and database access speeds.pydannyhttps://www.blogger.com/profile/00481523876497446983noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-37868736295425084072010-12-06T10:45:20.941-08:002010-12-06T10:45:20.941-08:00Don't you feel like Stupid Template Languages ...Don't you feel like Stupid Template Languages must be far faster than Smart ones? And the opposite sounds like a huge fail in, DTL, in particular?Sergey Shepelevhttps://www.blogger.com/profile/03622566552770711788noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-48401740761211250272010-12-06T09:17:10.318-08:002010-12-06T09:17:10.318-08:00@jalpino - I think a language or tool should be fl...@jalpino - I think a language or tool should be flexible, but a few hard or soft rules mean the difference between a big plate of spaghetti code and a maintainable project.<br /><br />For example, a lot of people don't like Python's use of whitespace to delineate code blocks. Yet I consider that a feature and probably 95% of the Python community agree with me. Should we add a setting to Python that lets you have the flexibility to turn that feature off or on as your developer feels it suits their needs?pydannyhttps://www.blogger.com/profile/00481523876497446983noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-12299317097576381022010-12-06T09:11:22.126-08:002010-12-06T09:11:22.126-08:00@cats2ndlife - Turning off Python code blocks in G...@cats2ndlife - Turning off Python code blocks in Genshi's configuration sounds useful, but my contention is that it shouldn't have the code blocks there in the first place.pydannyhttps://www.blogger.com/profile/00481523876497446983noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-41335766961435468242010-12-06T08:12:57.984-08:002010-12-06T08:12:57.984-08:00I thought flexibility in a language was a good thi...I thought flexibility in a language was a good thing? Templating with the ability to embed business logic isn't the fault of the language as much as it is the developer. What is to stop someone from embedding business logic in their controllers vs say a service layer?jalpinonoreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-54444385165663560942010-12-04T12:36:09.136-08:002010-12-04T12:36:09.136-08:00The way we use templating engines are really count...The way we use templating engines are really counter to the way that HTTP and hypertext was designed. <br /><br />There's an aspect of hypertext that we rarely talk about, but use blindlessly when we put an image on a page. It's the idea of transclusions. We use it all the time to insert an image on a page, but we rarely use it to include text on a page.<br /><br />I have found with some preliminary testing that by using RESTful resources, which can be cached edge side and then transcluding the resources client side with Ajax or "iframe seamless" performs extremely well.<br /><br /><br />You can see a preliminarily example of doing client-side<br />transclusion at this URI:<br /><br />http://dl.dropbox.com/u/1890692/hyperblog/index.html<br /><br />That URI presents two resources, an index page and an entry page with all the redundant site elements into the HTML pulled in using current transclusion techniques.<br /><br />If you view the source code on that page, you can see how the header and footers, because they are site elements and not resource elements, they're transcluded client side, just like any other static content. They can utilize the benefits of edge-side and client-side caching because they rarely change. This makes the only thing actually in the response, the actual resource being requested, which can be cached independently of the header and footer. <br /><br />I am not sure how constructive or destructive to SEO this is. I'd like to think that since only the relative resources are in the HTML, that it would help SEO because the HTML is a highly concentrated view of the content instead of a diluted version with dozens of unrelated links in the header and navigation.Erichttps://www.blogger.com/profile/02843284280678264725noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-71093647142057117662010-12-04T08:51:11.725-08:002010-12-04T08:51:11.725-08:00You can turn off Python code blocks in Genshi'...You can turn off Python code blocks in Genshi's configurations. You can also do that in ASP and JSPs too. If you don't want your team to put code blocks in templates, just turn it off. I always do that with Genshi and JSPs. While I agree with you on most of the points, I don't see having code blocks support in the template language is such a big deal. There are many instances using code blocks is clearer/easier to reason with. The only reason I turn off code blocks is because I don't want to mess up my markup IDE.cats2ndlifehttps://www.blogger.com/profile/12171138644670455341noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-61950550955753447442010-12-04T08:37:50.296-08:002010-12-04T08:37:50.296-08:00Hmm, I don't recall seeing any logic features ...Hmm, I don't recall seeing any logic features in metal. I don't quite see how business logic can be implemented using metal because it doesn't have any control flow terms. (vs. tal:condition)<br /><br />anyway I have a TAL implementation in xsl that also does METAL. I love it, I use it client side in the browser or server side with libxslt or lxml.<br /><br />I also have a javascript version of just tal, client-side.. works well enough for my needs.brad clementshttps://www.blogger.com/profile/12500394420477464688noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-8063959332894877212010-12-04T07:13:43.529-08:002010-12-04T07:13:43.529-08:00This comment has been removed by the author.mike bayerhttps://www.blogger.com/profile/01417862951114999907noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-13791841068265352792010-12-04T06:30:30.506-08:002010-12-04T06:30:30.506-08:00huxley - Brilliant! http://www.codeirony.com/?p=9huxley - Brilliant! http://www.codeirony.com/?p=9pydannyhttps://www.blogger.com/profile/00481523876497446983noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-22312318169773162262010-12-04T06:28:54.266-08:002010-12-04T06:28:54.266-08:00Petri - You are correct, METAL indeed does not let...Petri - You are correct, METAL indeed does not let you put business logic in your templates. But it lets you hide critical parts of your views in obscure places. How do I know? I did it myself!pydannyhttps://www.blogger.com/profile/00481523876497446983noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-8336203549330530662010-12-03T14:51:41.502-08:002010-12-03T14:51:41.502-08:00In my opinion, just the graph and the first two pa...In my opinion, just the graph and the first two paragraphs of Code Irony's "Fastest templating engine ever. Period." are the best things ever been written about template speed: <br /><br /><a href="http://www.codeirony.com/?p=9" rel="nofollow">Fastest templating engine ever. Period.</a>huxleynoreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-15258102166754607432010-12-03T14:26:53.280-08:002010-12-03T14:26:53.280-08:00I like templess, which isn't just stupid, it&#...I like templess, which isn't just stupid, it's positively moronic. :) But never get to use it. :-(<br /><br />http://pypi.python.org/pypi/templess/0.3Lennart Regebronoreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-48895848500530185952010-12-03T13:16:59.982-08:002010-12-03T13:16:59.982-08:00It could be argued that METAL is not really a macr...It could be argued that METAL is not really a macro language but a markup inclusion language with a somewhat misleading name. Hmm maybe it could be renamed to MIL? ;-P<br /><br />Despite having used TAL & METAL for many years, it never occurred to me to (ab)use METAL as means to put application logic into templates.<br /><br />Given their relatively verbose syntax, I have a feeling the syntax overhead of TAL & METAL might actually work as a deterrent against such abuse. Curious thought, that..<br /><br />But, since you are familiar with METAL and consider it too easy to abuse, perhaps there's something I did not understand. Care to elaborate a bit more?Petri Savolainennoreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-53021062834093214112010-12-03T11:30:27.585-08:002010-12-03T11:30:27.585-08:00Look at Twig and PHPTAL (for PHP templates)Look at Twig and PHPTAL (for PHP templates)Unknownhttps://www.blogger.com/profile/12868946672568809536noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-84937812889744463182010-12-03T08:44:16.721-08:002010-12-03T08:44:16.721-08:00print 'my preferred templating mechanism is ju...print 'my preferred templating mechanism is just %(template)s - simple but effective'%{'template':'string+dict'}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-2320160825368849702010-12-03T08:29:31.410-08:002010-12-03T08:29:31.410-08:00Hanno,
Thanks for the clarification. Chameleon lo...Hanno,<br /><br />Thanks for the clarification. Chameleon looks awesome, and if I ever used it I would write something that would check for xmlns:metal="http://xml.zope.org/namespaces/metal" in the templates and raise an error if it found it. :)pydannyhttps://www.blogger.com/profile/00481523876497446983noreply@blogger.comtag:blogger.com,1999:blog-4477131926658044957.post-30751294777708738602010-12-03T08:16:10.185-08:002010-12-03T08:16:10.185-08:00TAL in its Chameleon implementation isn't slow...TAL in its Chameleon implementation isn't slow at all. In terms of raw performance it's in the same league as Mako or Jinja2 - depending on the exact benchmark sometimes a bit faster and sometimes a bit slower, but essentially they all use the same basic approach.<br /><br />That said, choosing a template language isn't about performance anymore these days, as all the modern implementations compare equal on that level. So it's really your audience (developers vs. integrators / designers), the ease of use and other usability criteria which are key.Anonymousnoreply@blogger.com