February 2017 Archives

Your own template engine in 4 flavors. With Benchmarks!

This time on blog I'll show you how to write your own template engine - with syntax and behavior tailored for your needs. And we'll do it in four different ways to analyze pros and cons of each approach as well as code speed and complexity. Our sample task for today is to compose password reminder text for user, which can then be sent by email.

use v6;

my $template = q{
Hi [VARIABLE person]!

You can change your password by visiting [VARIABLE link] .

Best regards.
};

my %fields = (
'person' => 'John',
'…

About Pawel bbkr Pabian

user-pic GitHub LinkedIn