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 (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