我认为,CSS语法和基本原则可以非常有用,而不仅仅适用于样式。 是否有任何PARSE引擎可以使用类似CSS的规则操作,就像XML的规则一样?CSS语法不适用于STYLE
例如,我们可以创建类似框架(是的,另一个),其中我们在XML中定义的页面风格(JUST例如,也许很愚蠢或两个复杂):
<page id="index" url="/" controller="staticpage" />
<page id="about" url="/" controller="staticpage" action="about" />
<page id="post" url="/post/(\d+)" type="regex" controller="post" class="">
<param id="1" name="post_id" />
</page>
<page id="post_comment" url="/comment/(\d+)" type="regex" controller="post" action="comment" class="authneeded">
<param id="1" name="post_id" />
</page>
<page id="post_write" url="/write" type="regex" controller="staticpage" action="write" class="authneeded" />
然后写一个“CSS”:
* {
layout: "layout.html"; // default layout
}
*[action=''] {
action: "index"; // default action
}
#post_write {
layout: "adminlayout.html";
}
.authneeded {
redirect: "/";
}
.authneeded:loggedin { // pseudoclass which is set only if the user logged in.
// (maybe POSTS:loggedin .authneeded to apply only one
// pseudoclass)
redirect: false; // no, we don't need to redirect then the user logged in
}
这不是一个有趣的配置方式吗? 更妙的是,我们可以创建一个管理脚本(的jQuery的启发;)
./admin #about addClass authneeded
./admin "#post PARAM" attr id param_post
那么,有没有可以与CSS类规则的操作任何引擎?
这样做有没有什么好处,而不是坚持标准的metaformats? (见http://www.faqs.org/docs/artu/ch05s02。html)你有一个有趣的想法,但是什么是错误的,例如,为此使用YAML? – deau 2009-12-01 19:22:25
这看起来像JSON的工作! – 2009-12-01 19:22:59
在json中没有选择器 – 2009-12-01 20:15:23