X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2FManual%2FView.pod;h=01745ed8a5f6c6c15778f9fea03a4572c6917794;hb=628ecd5d9d294e601c79c7509140d02dcd7a1d40;hp=81ac57b8a15d33cd486c7a3ab13b136d3d9dcb29;hpb=5c0dc9d3fea7db57178e06139d681f5fc115d00c;p=maypole.git diff --git a/lib/Maypole/Manual/View.pod b/lib/Maypole/Manual/View.pod index 81ac57b..01745ed 100644 --- a/lib/Maypole/Manual/View.pod +++ b/lib/Maypole/Manual/View.pod @@ -18,7 +18,7 @@ lot to its preferred templating module, which will then do the hard work of filling in the template and coming up with the output. You can choose whatever Maypole view class you want, but the default -view class is C, and it feeds its data and templates +view class is L, and it feeds its data and templates to a module called the Template Toolkit. =head2 The Template Toolkit @@ -27,18 +27,22 @@ The Template Toolkit, written by Andy Wardley, is a very powerful and generic templating system. It provides its own little formatting language which supports loops, conditionals, hash and array dereferences and method calls, macro processing and a plug-in system to connect it to -external Perl modules. There are several good introductions to the +external Perl modules. +Its homepage is C. +There are several good introductions to the Template Toolkit available: you should have one installed as L; there's one at L, and of course there's the "Badger Book" - I, by Andy et al. +C We'll present a brief introduction here by deconstructing some of the templates used by Maypole applications. For more deconstruction, see -L, which is an entire chapter dealing with the +L, +which is an entire chapter dealing with the factory supplied templates. -Here's the template which is called for the front page of the standard +Here's a template that could be called for the front page of the example beer database application, C. [% INCLUDE header %] @@ -57,13 +61,13 @@ beer database application, C. The first thing to note about this is that everything outside of the Template Toolkit tags (C<[%> and C<%]>) is output verbatim. That is, -you're guaranteed to see +somewhere in the output you're guaranteed to see

The beer database

-in the output somewhere. Inside the tags, magic happens. The first piece +Inside the tags, magic happens. The first piece of magic is the C<[% INCLUDE header %]> directive. This goes away and finds a file called F
- don't worry about how it finds that yet, we'll come to that later on - and processes the file's contents as @@ -78,26 +82,30 @@ The next piece of magic is this line: We're seeing a lot of things here at once. C is where we should start looking. This is a template variable, which is what templates are all about - templating means getting data from somewhere outside and -presenting it to the user in a useful way, and the C hash is a -prime example of data that we want to use. It's actually the hash of -configuration parameters for this Maypole application, and one of the -keys in that hash is C, the database tables that we're -allowed to play with. In the application, we probably said something -like +presenting it to the user in a useful way, and C is a +prime example of data that we want to use. It's actually an object +containing configuration parameters for this Maypole application, and +one of the methods is C, which returns a list of the +database tables that we're supposed to show. In the application, we +probably said something like - BeerDB->config->{display_tables} = [qw[beer brewery pub style]]; + BeerDB->config->display_tables([qw[beer brewery pub style]]); This stores the four values - C, C, C and C