4 ms·
can you please explain what you mean by 'document-oriented templating language'?
by gingerlime 14y ago
can you please explain what you mean by 'document-oriented templating language'?
- ufo 14y agoBasically anything that doesn't have "raw text" as the underlying model and that actually understands that its dealing with HTML. I am a big fan of embedded DSLs so I prefer when I libraries that let you freely mix HTML generation with code, but in a structured way so we don't generate invalid or unescaped markup (things like PHP fall in this unstructured category). An example of the embeded DSL approach is Haskell's Blaze[1]. Perl's Template::Declare[2] and Ruby's Markaby[3] seem to use similar approaches but I never worked with them myself. [1] http://www.jaspervdj.be/blaze/tutorial.html http://www.jaspervdj.be/blaze/tutorial.html [2] http://search.cpan.org/dist/Template-Declare/lib/Template/Declare.pm#SYNOPSIS http://search.cpan.org/dist/Template-Declare/lib/Template/De... [3] http://markaby.rubyforge.org/ http://markaby.rubyforge.org/ There are also more "templaty" alternatives that don't let you use the full power of an embeded DSL but that sitll assume that you are generating a document (instead of raw text) there are things like Hamlet[4]. I am sure there are also other similar examples fore mainstream languages but as I said, I like the embeded DSL stuff better... [4]http://hackage.haskell.org/package/hamlet http://hackage.haskell.org/package/hamlet
- gingerlime 14y agoThanks. Some interesting links and an interesting approach. Having looked (very briefly) into markaby, as far as I understand, the problem is still there to some extent though: "When you call helper methods inside Markaby, the output from those methods will be output to the stream. This is incredibly handy, since most Rails helpers output HTML tags."
- masklinn 14y ago> I am sure there are also other similar examples fore mainstream languages For Python, there's Genshi: http://genshi.edgewall.org/ http://genshi.edgewall.org/