[% # Use the TT Dumper plugin to Data::Dumper variables to the browser -%] [% # Not a good idea for production use, though. :-) 'Indent=1' is -%] [% # optional, but prevents "massive indenting" of deeply nested objects -%] [% USE Dumper(Indent=1) -%] [% # Set the page title. META can 'go back' and set values in templates -%] [% # that have been processed 'before' this template (here it's for -%] [% # root/lib/site/html and root/lib/site/header). Note that META on -%] [% # simple strings (e.g., no variable interpolation). -%] [% META title = 'Book Created' %] [% # Output information about the record that was added. First title. -%]
Added book '[% book.title %]' [% # Output the last name of the first author. This is complicated by an -%] [% # issue in TT 2.15 where blessed hash objects are not handled right. -%] [% # First, fetch 'book.authors' from the DB once. -%] [% authors = book.authors %] [% # Now use IF statements to test if 'authors.first' is "working". If so, -%] [% # we use it. Otherwise we use a hack that seems to keep TT 2.15 happy. -%] by '[% authors.first.last_name IF authors.first; authors.list.first.value.last_name IF ! authors.first %]' [% # Output the rating for the book that was added -%] with a rating of [% book.rating %].
[% # Provide a link back to the list page -%] [% # 'uri_for()' builds a full URI; e.g., 'http://localhost:3000/books/list' -%] [% # Try out the TT Dumper (for development only!) -%]Dump of the 'book' variable: [% Dumper.dump(book) %]