惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
博客园_首页
雷峰网
雷峰网
V
Visual Studio Blog
爱范儿
爱范儿
A
About on SuperTechFans
量子位
N
Netflix TechBlog - Medium
Microsoft Security Blog
Microsoft Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
S
SegmentFault 最新的问题
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More

Secret Weblog

Becoming More Xee: A Modern XPath and XSLT Engine in Rust Looking for new challenges! Repeat Yourself, A Bit The Curious Case of Quentell The Humble For Loop in Rust The Humble For Loop in JavaScript Don Question Best Practices I Was a 1980s Teenage Programmer Part 5: Achieving Assembly I Was a 1980s Teenage Programmer Part 4: The Call of Assembly The Tooling Shift I Was a 1980s Teenage Programmer Part 3: MSX-2 JavaScript: when you need two ways to do it! Empowering Programming Languages Bloat and Retrofuturism Refreshing my Blog Again Random Rust Impressions Apilar: An Alife System I Was a 1980s Teenage Programmer Part 2: Olivetti M24 I Was a 1980s Teenage Programmer: the Alphatronic SolidJS fits my brain Is premature optimization the root of all evil? Framework Patterns: JavaScript edition Roll Your Own Frameworks Framework Patterns Secret Weblog Highlights Refactoring to Multiple Exit Points mstform: a form library for mobx-state-tree Seven Years: A Very Personal History of the Web
the Clarity Template Language
Martijn Faassen · 2005-04-16 · via Secret Weblog

The ClearSilver templating language does not have a very pleasant syntax for people familiar with the TAL notation of Zope Page Templates. That's not to say ClearSilver's syntax is awful; it's deliberately simple, and I'm sure one could get used to it pretty quickly. Still, I started wondering what ClearSilver syntax would look like if it were more like TAL. Let's call such a theoretical TAL-like ClearSilver "Clarity". Perhaps this is a bit confusing, as it's the same name as the ClearSilver integration package I talked about before, but it's a nice name. :)

The Clarity templating language could be seen as a simple frontend to ClearSilver, meaning there is a one-to-one mapping of any Clarity code to ClearSilver code.

I realized that it should be possible to implement such a frontend fairly easily by involving yet another templating language: XSLT. I could use an XSLT template to translate Clarity templates to the equivalent ClearSilver templates.

So, I started an experiment. So far it's working out fairly well, though only a very limited set of ClearSilver commands can be produced right now (just var and set). Clarity right now defines the following statements: cs:define, cs:content and cs:replace, which more or less work like the equivalents in TAL, though the define syntax and semantics are different (that of set in ClearSilver). I even added support for "structure", in that I use the ClearSilver html_quote() by default everywhere, unless "structure" is used.

Pretty neat stuff, though somewhat perverse. I could even integrate this into the Clarity Zope 3 package using lxml, so that any .cla templates will be automatically preprocessed to ClearSilver templates whenever needed...

And for the people who know him, no, this is not a secret project to drive Paul Everitt completely nuts. :)

The code can be found here:

http://codespeak.net/svn/z3/clarity/trunk/xslt/

In particular, here's an example of Clarity code:

http://codespeak.net/svn/z3/clarity/trunk/xslt/example.cla