1Template::Plugin::AsserUts(e3r)Contributed Perl DocumentTaetmipolnate::Plugin::Assert(3)
2
3
4
6 Template::Plugin::Assert - trap undefined values
7
9 [% USE assert %]
10
11 # throws error if any undefined values are returned
12 [% object.assert.method %]
13 [% hash.assert.key %]
14 [% list.assert.item %]
15
17 This plugin defines the "assert" virtual method that can be used to
18 automatically throw errors when undefined values are used.
19
20 For example, consider this dotop:
21
22 [% user.name %]
23
24 If "user.name" is an undefined value then TT will silently ignore the
25 fact and print nothing. If you "USE" the "assert" plugin then you can
26 add the "assert" vmethod between the "user" and "name" elements, like
27 so:
28
29 [% user.assert.name %]
30
31 Now, if "user.name" is an undefined value, an exception will be thrown:
32
33 assert error - undefined value for name
34
36 Andy Wardley <abw@wardley.org> <http://wardley.org/>
37
39 Copyright (C) 2008 Andy Wardley. All Rights Reserved.
40
41 This module is free software; you can redistribute it and/or modify it
42 under the same terms as Perl itself.
43
45 Template::Plugin
46
47
48
49perl v5.30.1 2020-01-30 Template::Plugin::Assert(3)