auto_template
Table of Contents |
新仕様案とその実装
現在の仕様
どう頑張っても、Hoge/Foo/Bar -> Hoge/Foo/template -> Hoge/template -> template のようにはできない。限度がある。
ところで、
$non_list = '^\:|(^|\/)template$'
デフォルトでいいのではないだろうか。
参照
- org:続・質問箱/172
- 雛形のページって作れませんでしたっけ?
$auto_template_rules = array( '((.+)\/([^\/]+))' => ':template/\2', '((.+)\/([^\/]+))' => ':template', '(()(.+))' => ':template' );
- org:続・質問箱/95
- 雛形変数
- org:質問箱/277
- 階層化していない時のテンプレート利用
$auto_template_rules = array( '(()(.+))' => ':template' );
- org:質問箱/316
- 雛型とするページで記号を最初にしたい
$auto_template_rules = array( '((.+)\/([^\/]+))' => '_Template/\2' );
- org:質問箱3/137
- template_rules の適用順位
- org:質問箱3/164
- template/MenuBar もしくは MenuBar/template
$auto_template_rules = array( '^((.+\/)?([^\/]+))(?# ~templateを適用 )$' => '$3/template', '^((.+\/)?([^\/]+))(?# template~を適用 )$' => 'template/$3', );
- org:質問箱3/336
- 順繰り順繰り上階層
$auto_template_rules = array( '((.+)\/([^\/]+))' => '\2/template', '((.+)\/(.+)\/([^\/]+))' => '\2/template', '((.+)\/(.+)\/(.+)\/([^\/]+))' => '\2/template', '((.+)\/(.+)\/(.+)\/(.+)\/([^\/]+))' => '\2/template', '((.+)\/(.+)\/(.+)\/(.+)\/(.+)\/([^\/]+))' => '\2/template', '[^\/]+' => 'template', );
- dev:BugTrack/299
- テンプレート内に置換文字設定
- dev:PukiWiki/1.4/マニュアル/テンプレート
$auto_template_rules = array( '((.+)\/([^\/]+))' => '\2/template', );
新仕様案
Hoge/Foo/Bar -> Hoge/Foo/template -> Hoge/template -> template とできるようにする。
Hoge/Foo/Bar が Hoge/Foo/template にマッチした場合、 $0 が Hoge/Foo/Bar, $1 が Hoge/Foo $2 が Bar、
Hoge/template にマッチしたら $0 は同じく全体で、$1 が Hoge $2 が Foo/Bar
この点は固定されるので、旧版に比べて劣っているように見えるかもしれないが、これで充分だと思う。
$auto_template_suffix = 'template'; $matches[0] = $page; while (($page = dirname($page)) != '.')) { if (is_page($page . '/' . $auto_template_suffix)) { $template = $page . '/' . $auto_template_suffix; $matches[1] = $page; $matches[2] = substr($matches[0], strlen($matches[1]) + 1); break; } } if ($page == '.') { if (is_page($auto_template_suffix)) { $template = $auto_template_suffix; $matches[1] = ''; $matches[2] = $matches[0]; } } if (! isset($template)) { Not Found! }