This commit is contained in:
2026-06-26 10:03:51 -06:00
parent ac2ad23230
commit 3382f6d33f

View File

@@ -24,8 +24,8 @@
I like writing Perl, I want to write Perl, so when I have to switch contexts to HTML it annoys me. To compound this problem, I just got off a project that used a tool called
<a href="https://github.com/weavejester/hiccup">hiccup</a>, hiccup let me write code in its native toungue (Clojure), and get back HTML in the form of a string. This rocked!
Not only did I not have to write HTML, it was actually <i>intuitive</i>, it provided me with a DSL for HTML. So I took this idea, and ported it to Perl, in the form of
<a href="https://metacpan.org/pod/HTML::Composer">HTML::Composer</a>. HTML::Composer is a library that does its best to emulate that sort of intuitiveness, and to my surprise,
it seems to.
<a href="https://metacpan.org/pod/HTML::Composer">HTML::Composer</a>. HTML::Composer is a library that does its best to emulate that sort of intuitiveness, inside of Perl. To my surprise
it seems to, and even more suprisingly, it performs incredibly well.
</p>
<h2>HTML::Composer</h2>
<p>
@@ -66,10 +66,10 @@ my $html = $h->partial([
]
]);
say $html;
say $html; # &lt;div&gt;Hello, World!&lt;a href="https://www.google.com"&lt; ...
</code></pre>
<p>
Since HTML::Composer operates inside of Perl data structures, and doesn't need to parse HTML, it's quite fast. Faster than any other HTML templating library I could find.
Since HTML::Composer operates inside of Perl data structures, and doesn't need to do any string parsing, it's quite fast. Faster than any other templating library outputting HTML I could find.
The following benchmark is the average of five different one-hundred-million iteration runs rendering a medium sized HTML page that changed between iterations,
with the caveat being, each of these libraries was expected to take an input scalar and output to a scalar variable (Text::Xslate is optimized to read from a file not a string, so it hated this benchmark):
</p>