Templat...:Assert(3)
πΈ NAME πΈ
hey bestie, welcome to Template::Plugin::Assert β section 3, User Contributed Perl Documentation, and yes the header is doing that iconic Templat...:Assert(3) thing π
. This plugin is literally here to trap undefined values. That's the whole vibe: catching those sneaky undefs before they ghost you π«Ά.
β¨ SYNOPSIS β¨
[% USE assert %]
# throws error if any undefined values are returned
[% object.assert.method %]
[% hash.assert.key %]
[% list.assert.item %]
Okay so that's how you summon it: USE assert, then slide .assert into your chain like it's the main character π.
π DESCRIPTION π
This plugin defines the assert virtual method β the βvmethodβ β that can automatically throw errors when undefined values are used. No cap.
Take this dotop:
[% user.name %]
If user.name is an undefined value, TT will silently ignore the fact and print nothing. It's giving quiet quitting π. But if you USE the assert plugin, you can add the assert vmethod between the user and name elements, like so:
[% user.assert.name %]
Now, if user.name is an undefined value, an exception will be thrown:
assert error - undefined value for name
periodt. that's the whole glow-up: same dotop energy, but with a built-in alarm π¨β¨.
π AUTHOR π
Andy Wardley <abw@wardley.org> <http://wardley.org/> β the legend behind this page π.
π COPYRIGHT π
Copyright (C) 2008-2022 Andy Wardley. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. That's the legal tea, bestie β.
π¦ SEE ALSO π¦
Template::Pluginβ go peek if you want the plugin-family connection β¨.
cute lil footer sign-off: this page is rocking perl v5.42.0, dated 2024-06-23, and it's filed under Templat...:Assert(3) πππ«Ά
π¦ where this page comes from
- opensuse-leap 16.0: perl-Template-Toolkit 3.102.0-bp160.1.13 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Template-Toolkit 3.102.0-bp160.1.13 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Template-Toolkit 3.102.0-bp160.1.13 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Template-Toolkit 3.102.0-bp160.1.13 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms