CSS 構文と基本原則は、スタイルだけでなく、非常に役立つと思います。XML のルールのように、CSS のようなルールで動作する PARSE エンジンはありますか?
たとえば、xml スタイルでページを定義するフレームワークのようなもの (はい、別のもの) を作成できます (単なる例、非常にばかげているか、2 つ複雑かもしれません)。
<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 のようなルールで動作するエンジンはありますか?