TTSiteの基本構造構成以下のようにヘルパーコマンドを実行する。 script/myapp_create.pl view TT TTSite すると、以下のような構成のファイル・ディレクトリが作成される。 lib/MyApp/View/TT.pm
root/
src/
static/
lib/
config/
main
col
url
site/
html
layout
wrapper
lib/MyApp/View/TT.pmTTインスタンス生成時の設定をする。 package MyApp::View::TT;
use strict;
use base 'Catalyst::View::TT';
__PACKAGE__->config({
CATALYST_VAR => 'c',
PLUGIN_BASE => 'MyApp::TT',
INCLUDE_PATH => [
MyApp->path_to( 'root', 'src' ),
MyApp->path_to( 'root', 'lib' )
],
PRE_PROCESS => 'config/main',
WRAPPER => 'site/wrapper',
ERROR => 'error.tt2',
TIMER => 0,
DEBUG => 'undef',
});
root/lib/config/mainTTインスタンス生成時のPRE_PROCESSの指定により、root/lib/config/mainファイルがロードされる。 [% # config/main
#
# This is the main configuration template which is processed before
# any other page, by virtue of it being defined as a PRE_PROCESS
# template. This is the place to define any extra template variables,
# macros, load plugins, and perform any other template setup.
IF c.debug;
# define a debug() macro directed to Catalyst's log
MACRO debug(message) CALL c.log.debug(message);
END;
# define a data structure to hold sitewide data
base = c.req.base;
site = {
title => 'Example Site',
copyright => 'www.example.com',
base => c.req.base,
};
# set defaults for variables, etc.
DEFAULT
message = 'There is no message';
-%]
root/lib/site/wrapperTTインスタンス生成時の設定でWRAPPERが指定されいるので、まずWRAPPERファイル(root/lib/site/wrapper)がロードされる。 [% IF template.name.match('\.(css|js|txt)');
debug("Passing page through as text: $template.name");
content;
ELSE;
debug("Applying HTML page layout wrappers to $template.name\n");
content WRAPPER site/html;
END;
-%]
root/src/***.tt2 statc/***.cssCatalyst本体で指定したテンプレートファイルがロードされる。 |
|