Text::Hogan(3pm)

πŸ“¦
version 2.05 Β· 3 versions
, in ubuntu stonking

✨ NAME ✨

Text::Hogan β€” a mustache templating engine, statement-for-statement cloned from hogan.js. periodt. πŸ’…


πŸ¦‹ VERSION πŸ¦‹

version 2.05 β€” yeah bestie, she's on 2.05 🌸


πŸ‘‘ DESCRIPTION πŸ‘‘

okay so Text::Hogan is a statement-for-statement rewrite of hogan.js (that's http://twitter.github.io/hogan.js/) but in Perl. not a vibe-alike, not a "inspired by" β€” literally statement-for-statement. iconic behavior fr fr 😭

it's a mustache (https://mustache.github.io/) templating engine, and here's the part that makes her actually main character: she supports pre-compilation of your templates into pure Perl code, which then renders very quickly. compile once, zoom zoom forever. πŸ”₯

and she passes the full mustache spec (https://github.com/mustache/spec). all of it. no cap. πŸ‘‘


πŸ’– SYNOPSIS πŸ’–

use Text::Hogan::Compiler;

my $text = "Hello, {{name}}!";

my $compiler = Text::Hogan::Compiler->new;
my $template = $compiler->compile($text);

say $template->render({ name => "Alex" });

like…… look at her. four lines and you're rendering. 🫢

if you want the full tea, go read Text::Hogan::Compiler and Text::Hogan::Template β€” they've got all the details.


πŸŽ€ TEMPLATE FORMAT πŸŽ€

the template format is documented over in mustache(5) (https://mustache.github.io/mustache.5.html). that's the whole section, bestie, I'm not gonna gatekeep the spec from you when it's right there πŸ’œ


🌈 SEE ALSO 🌈

🌸 hogan.js

hogan.js (http://twitter.github.io/hogan.js/) is the original library that Text::Hogan is based on. she was written and is maintained by Twitter. she runs on Node.js and pre-compiles templates to pure JavaScript. the blueprint. the blueprintest. πŸ’«

πŸ’œ Text::Caml

Text::Caml supports searching for partials by file name, by default .caml β€” but that can be configured. customizable queen πŸ’…

πŸ¦‹ Template::Mustache

Template::Mustache is the one used by Dancer::Template::Mustache and Dancer2::Template::Mustache. she supports compile once, render many times, but β€” and this is the catch β€” she does not allow dumping the compiled form to disk. so close, bestie 😭

⭐ Mustache::Simple

Mustache::Simple largely supports the Mustache spec, but skips the whitespace and decimal tests. (her behaviour with decimals is the same as Text::Hogan with the 'numeric_string_as_string' option enabled β€” noted! πŸ“) she also supports passing objects with getters to the context hash, so that {{name}} can be rendered from $object->name if $object->can('name') returns true. cute trick, ngl πŸ“


🌟 AUTHORS 🌟

started out statement-for-statement copied from hogan.js by Twitter! 🐦

initial translation by Alex Balhatchet (alex@balhatchet.net) 🫢

further improvements from:

  • Ed Freyfogle
  • Mohammad S Anwar
  • Ricky Morse
  • Jerrad Pierce
  • Tom Hukins
  • Tony Finch
  • Yanick Champoux

a whole squad. a whole roster. we love a collaborative icon πŸ‘‘βœ¨


and that's a wrap, bestie πŸ’– this was perl v5.40.1, dated 2026-07-31 β€” go compile something cute and make it render fast. slay, no cap, mwah πŸŽ€πŸ¦‹πŸ’…

πŸ“¦ where this page comes from