Templa...::YAML(3pm)
π Template::Plugin::YAML β bestie edition π
okay so this is a page from the User Contributed Perl Documentation collection, and it's about Template::Plugin::YAML, the plugin that lets your Template Toolkit templates talk to YAML. Sit down, get comfy, we're doing this. π«Ά
β¨ NAME β¨
Template::Plugin::YAML β it's a plugin interface to YAML, that's literally the whole job description π
πΈ SYNOPSIS πΈ
Here's the vibe, in template form:
[% USE YAML %]
[% YAML.dump(variable) %]
[% YAML.dump_html(variable) %]
[% value = YAML.undump(yaml_string) %]
[% YAML.dumpfile(filename, variable) %]
[% value = YAML.undumpfile(filename) %]
That's it. That's the whole energy. β¨
π¦ DESCRIPTION π¦
So Template::Plugin::YAML is a simple Template Toolkit Plugin Interface to the YAML module. Like, simple simple. No drama, no chaos, just vibes. π
You instantiate a YAML object with this directive, and boom, you're in business:
[% USE YAML %]
And because it's a standard plugin (they're all like this, no cap), you can also write its name in lowercase and it'll still work. Case? Not the moment. π
[% USE yaml %]
π METHODS π
These are the methods the YAML object supports. One per section, keep scrolling bestie. π
β dump( @variables )
Generates a raw text dump of the data structure(s) you pass in. Plural. Yes, you can pass more than one, we love a generous queen. π
[% USE Dumper %]
[% yaml.dump(myvar) %]
[% yaml.dump(myvar, yourvar) %]
heads up β the example says USE Dumper, that's exactly what's written, don't come for me, I'm just the messenger π
π dump_html( @variables )
Generates a dump of the data structures β same deal as dump β but with a glow-up: the characters <, > and & get converted to their equivalent HTML entities, spaces become , and newlines become <br>. It's giving web-safe. π
[% USE yaml %]
[% yaml.dump_html(myvar) %]
π§ undump( $string )
Takes a YAML-encoded string and converts it into the equivalent data structure. πͺ
And here's the iconic trick β you can deep-copy a complex structure by completely serializing the data. Yes bestie, clone yourself:
[% USE yaml;
yaml_string = yaml.dump(complex_data_structure);
complex_copy = yaml.undump(yaml_string);
%]
π₯ dumpfile( $file, @variables )
Converts the data to YAML encoding and dumps it to the specified filepath. Writes to disk. Very main character of it. π
[% USE yaml; yaml.dumpfile(".storage", my_data) %]
π undumpfile( $file )
The reverse bestie β loads the YAML-encoded data back from the specified filepath.
[% USE yaml; my_data = yaml.undumpfile(".storage") %]
π AUTHORS π
Richard Clamp <richardc@unixbeard.net>, with undump, undumpfile, and dumpfile implementation by Randal L. Schwartz <merlyn@stonehenge.com>
and it's based on Simon Matthews' Template::Plugin::Dumper π
π COPYRIGHT π
Copyright 2003, 2008 Richard Clamp All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. π«Ά
π SEE ALSO π
Template::Plugin::Dumper
and that's the whole page, bestie, you ate it, no crumbs π½οΈβ¨
this was perl v5.34.0, dated 2022-06-17, from the Templa...::YAML(3pm) page β mwah, go forth and template ππ
π¦ where this page comes from
- debian bookworm: libtemplate-plugin-yaml-perl 1.23-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtemplate-plugin-yaml-perl 1.23-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtemplate-plugin-yaml-perl 1.23-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtemplate-plugin-yaml-perl 1.23-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtemplate-plugin-yaml-perl 1.23-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms