Skip to content
Perl6 library for the Mustache template format
Raku Shell Other
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/Template Be less restrictive during tag parsing - Closes 26 Feb 10, 2019
logotype Make logo more legible Jun 20, 2014
t Test field lookup with defined, not truthiness Feb 3, 2019
tools Simplify tools/mkreadme [ci skip] Sep 27, 2017
.appveyor_clear_cache.txt Don't try `zef build .` Feb 3, 2019
.gitignore Use skip instead of todo when missing spec tests Apr 29, 2015
LICENSE Rename LICENSE [ci skip] Dec 3, 2017
META6.json Add Test::META; include a copy of spec tests Sep 27, 2017 Update Nov 5, 2019
appveyor.yml Don't try `zef build .` Feb 3, 2019

Perl6 implementation of Mustache templates,

Build Status Windows status


use Template::Mustache;

# Call .render as a class method
Template::Mustache.render('Hello, {{planet}}!', { planet => 'world' }).say;

# Or instantiate an instance
my $stache = :from<./views>;

# Subroutines are called
say $stache.render('The time is {{time}}', {
    time => { }

my @people =
    { :name('James T. Kirk'), :title<Captain> },
    { :name('Wesley'), :title('Dread Pirate'), :emcee },
    { :name('Dana Scully'), :title('Special Agent') },

# See this template in ./t/views/roster.mustache
$stache.render('roster', { :@people }).say;

my %context =
    event => 'Masters of the Universe Convention',
my %partials =
    welcome =>
        qq:b{Welcome to the {{event}}! We’re pleased to have you here.\n\n},

# See this result in ./t/50-readme.t
        {{> welcome}}
        {{> roster}}

            Dinner at 7PM in the Grand Ballroom. Bring a chair!
    :from([%partials, './views'])

More Examples and Tests

The Mustache spec provides a wealth of examples to demonstrate exactly how the format behaves.

To run tests,

# NB Ensure you are using the default 'perl6' branch, not 'master'
git clone ../mustache-spec
PERL6LIB=./lib prove -e perl6 -v

All spec tests pass: The perl6 branch just updates the .json files to match the .yml sources (needed until someone writes a Perl 6 YAML parser, hint, hint), and adds perl6 lambda code strings for that portion of the specs.

Other Mustache Implementations

There are many, many Mustache implementations in various languages. Some of note are:


  • object support (not just hashes and arrays)

  • parsed template caching

  • global helpers (context items that float at the top of the stack)

  • template inheritance:, etc.

  • database loader

  • pragmas (FILTERS?)


Artistic License 2.0

You can’t perform that action at this time.