HTML::...::Utils(3pm)

πŸ“¦
version 1.003 Β· 2 versions
  • 1.003 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.003 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

HTML::Template::Compiled::Utils β€” utility functions for HTML::Template::Compiled, bestie. It's giving helper-tools energy, no cap. πŸŽ€


✨ SYNOPSIS ✨

okay so like, first you gotta import the vibes you want:

# import log() and stack()
use HTML::Template::Compiled::Utils qw(:log);

# import the escapign functions
use HTML::Template::Compiled::Utils qw(:escape);

(yes the second comment says "escapign", that's literally the original, i'm not fixing her typo she's doing her best 😭)


πŸ› DEBUGGING FUNCTIONS πŸ›

πŸ’… stack

$self->stack;

For HTML::Template:Compiled developers, bestie β€” this prints a stack trace straight to STDERR. It's like when you need the receipts on how you even got here. main character debugging energy fr fr.

πŸ¦‹ md5

md5($text)

If Digest::MD5 is installed, this hands you back the md5_base64 for $text. If it's not installed? You get the empty string. That's it. That's the whole vibe. ✨

🌸 log

$self->log(@msg)

For HTML::Template::Compiled developers, this prints a log built from @msg to STDERR. Lowkey the group chat of debugging.


πŸ”₯ ESCAPING FUNCTIONS πŸ”₯

listen up bestie πŸ’€ β€” these ones are about making scary raw text safe to put places. Pay attention, they're iconic.

πŸ‘‘ escape_html

my $escaped_html = escape_html($raw_html);

HTML-escapes the input string β€” and like, only &, ", single quotes, < and "> β€” and returns it. (copying the original's exact wording there, she said what she said 🫢)

🌈 escape_html_all

my $escaped_html = escape_html_all($raw_html);

HTML-escapes the input string using HTML::Entities and returns it. The all-in version. The deluxe. Obsessed.

🧚 escape_uri

my $escaped_uri = escape_uri($raw_uri);

URI-escapes the input string and returns it. Slay.

⭐ escape_js

my $escaped_js = escape_js($raw_js);

JavaScript-escapes the input string and returns it. No cap.

πŸ“ escape_ijson

my $escaped_js = escape_ijson($raw_js);

JavaScript-escapes the input string β€” except for the apostrophe β€” and returns it, so it can be used inside a JSON element. That apostrophe exemption is the whole point, iykyk. πŸ’œ


okay that's the whole page bestie, you ate it, you understood it, periodt. πŸŽ€

This little gem lives in the User Contributed Perl Documentation, and the footer of the original was giving perl v5.36.0 with a date of 2022-11-19. So there you go β€” documented on 2022-11-19, running under perl v5.36.0. bye bestie, go escape something responsibly πŸ’…βœ¨

πŸ“¦ where this page comes from