4 ms·
One thing puzzles me: If LESS is essentially a template language specialized for CSS, why not reuse the template engine that you use in your application anyway?
by vog 16y ago
One thing puzzles me: If LESS is essentially a template language specialized for CSS, why not reuse the template engine that you use in your application anyway?
That way, you'd also have the benefit of defining often-used attribute values (e.g. colors) in a variable, and you could also group often-used combinations of attributes together in a variable or sub template.
- edanm 16y agoI wonder why there is no general "template" language that you can use on any text/source file. For example, I'm writing a lot of AutoHotKey code lately, and I find myself wishing I had some of the expressive power of Python so I wouldn't have to repeat things. I'm seriously considering writing a Python-based "Preprocessor" language which lets me drop in Python code on any file, and deals with transforming it into the final "compiled" file.
- vog 16y ago> I'm seriously considering writing a Python-based "Preprocessor" language which lets me drop in Python code on any file You are probably interested in Pyratemp – a simple, well-designed and well-documented template engine that allows arbitrary Python expressions: http://www.simple-is-better.org/template/pyratemp.html http://www.simple-is-better.org/template/pyratemp.html BTW, I personally use the XSLT template language. It is language independent, but still extendable with user-defined functions written in the programming language of your application. Note that despite its name, XSLT does not only provide for XML output, but handles text output and HTML as well. In Python, you can find a excellent XSLT processor in the 4suite package: http://4suite.org/docs/CoreManual.xml#xslt_engine http://4suite.org/docs/CoreManual.xml#xslt_engine However, the syntax of XSLT is a bit clumsy, so I'll probably switch to XQuery in the future.
- draegtun 16y agoI wonder why there is no general "template" language that you can use on any text/source file Template Toolkit is such a beast: http://template-toolkit.org/ http://template-toolkit.org/ Beyond its normal Perl (and Python) web templating usage I've also used (and abused) TT for: * All my static websites * CSS (dynamic and static) * Pre-process scripts (including Javascript) * Multi-lingual email * Creating (end user) configurable data exports (eg. CSV). * Websurvey language! * And probably other things I've (hopefully!) forgotten :) NB. See "ttree" & "tpage" in docs for standalone usage.
- ori_b 16y agoWe're going back to M4 now, but with python?
- edanm 16y agoThanks for that, never heard of that. Link for anyone interested: http://en.wikipedia.org/wiki/M4_(computer_language) http://en.wikipedia.org/wiki/M4_(computer_language). By the way, I really think that to work (i.e. become usable, maybe even popular), this needs to be built on an existing and popular language. Otherwise it's too steep a learning curve. Ideally, I'd like to be able to put in code in the text file wherever I want, be able to put the value of expressions in the code, and that's it.
- vog 16y agoM4 is not as unpopular as you might think. It is the base of GNU Autoconf, so everyone who touched a configure.in / configure.ac file did in fact work on M4 code. (... which is then expanded to a portable shell script also known as the ./configure script.)
- bockris 16y agoI'm late to the game but you should check out 'Cog' by Ned Batchelder. http://nedbatchelder.com/code/cog/ http://nedbatchelder.com/code/cog/ I used it several years ago with great success.
- alnayyir 16y agoFramework independence