我認爲,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