|
NAMEJifty::View::Declare::Page::NewStyle - new style page wrapper to simplify customization and reuse.DESCRIPTIONThis library is a replacement for Jifty::View::Declare::Page. That is in Jifty for a while and can not be replaced with something completely different because of backwards compatibility.When you declare a Jifty::View::Declare template that is a page, for example: template 'news' => page { ... }; Page classes come into game. First of all App::View::Page is loaded (it's not true and there is a way to define class for particular page, but lets leave it alone as interface is not settled enough to be discussed). If the app class doesn't exist then default Jifty::View::Declare::Page is used. Code block right after page token is used to render core of the page wrapped into some layout. Page classes implement such layouts. It's very hard to extended Jifty::View::Declare::Page class as it's written in such a way that forces you to copy&paste some internals from the class to make overridden method work and don't break things. I think this implementation is much better thing. To use this class as a base for all your pages you can just add this plugin to your app and simple YourApp::View::Page will be generated for you. However, if you're here then you want to change layout, your App::View::Page should be something like: package MyApp::View::Page; use base qw(Jifty::Plugin::ViewDeclarePage::Page); use Jifty::View::Declare::Helpers; ... 1; DIFFERENCES FROM DEFAULT PAGE CLASS
ACCESSORS
METHODSInitialization and rendering drivernewSets up a new page class. Called by Jifty with content_code and optional _meta. Calls "init" right before returning new instance of the class. init Sets _title accessor from 'title' in _meta if the latter is defined, so you can do the following if title of a page is static: template news => page { title => _('News') } content { ... }; render Renders whole page from doctype till closing html tag. Takes no arguments. This method drives rendering of the page. Page is split into three major parts: header, body and footer. Each is implemented as corresponding method with 'render_' prefix. It worth to note that order of rendering is changed and header is rendered after the body to allow you define page title, RSS feeds and other things in content. Read more about this below in "render_header" and "instrument_content". Main blocks of the pagerender_headerRenders an HTML "doctype" and complete <head> tag. Usually you don't want to override this. This method is rendered after body and main content of the page, so all things you need in head tag you can define in content.
render_body Renders body tag, declares that we're in body and calls "render_page" that actually defines layout of the body. "render_page" method is better target for subclassing instead of this. render_footer Renders the page footer - </html> tag :) Body layoutrender_pageRenders the skeleton of the page and then calls "instrument_content" to prepare and finally render "content_code" using "render_content". Default layout of the page is the following: <div> <div> this->render_salutation this->render_navigation </div> <div id="content"><div> this->instrument_content this->render_jifty_page_detritus </div></div> </div> instrument_content Something you don't want ever touch. However, does the following:
render_content Renders content of the page - "content_code". Helpersrender_doctypeRenders default doctype (HTML5) and opening "<html>" tag render_title_inhead Should output nothing but a title tag what will be placed into the head. Title is passed as only argument. Arguments are combined. render_title_inpage Renders the in-page title, followed by page navigation and jifty messages. See "render_title_inhead", "instrument_content" and "render_header". render_links_inhead Renders link tags which are passed as list of hashes. render_link_inpage Do nothing by default, but link as a hash is passed when content has 'add rel ...' or 'add rev ...'. Read more in "render_header" and "instrument_content". render_navigation Renders "navigation" in Jifty::Web as menu wrapped into a div with id 'navigation'. There is as well page_navigation in Jifty that is rendered in "render_title_inpage" by default. Called from "render_page". render_salutation Renders salutation for the current user wrapped into div with id equal to 'salutation'. Called from "render_page". render_jifty_page_detritus Renders admin mode warning, the wait message, and the keybindings javascript. Called from "render_page".
Visit the GSP FreeBSD Man Page Interface. |