Skip to content
dev
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
doc
 
 
 
 
lib
 
 
t
 
 
 
 
 
 
 
 
 
 

Stache

nb: This project currently has an unstable API! Minor version changes may break existing code.

Stache is an extensible mustache-style templating engine.

Basic Use

Raku script:

use Stache;

my $template = q:to/EOT/;
say '> # This is some {{ lang }} code';
say '> {{ code }}';
say {{ code }};
EOT

say Stache::render(
    $template,
    lang => 'Raku',
    code => '1 + 1',
);

Output:

say '> # This is some Raku code';
say '> 1 + 1';
say 1 + 1;

Structure Blocks

With Blocks

Raku script:

use Stache;

my $template = q:to/EOT/;
{{ with A }}
name: {{ .name }}
type: {{ .type }}
{{ endwith }}
EOT

say Stache::render(
    $template,
    A => %(
        name => '',
        type => 'language',
    ),
);

Output:

name: 楽
type: language

For Blocks

Raku script:

use Stache;

my $template = q:to/EOT/;
{{ for items }}
shape: {{ .shape }}
genus: {{ .holes }}

{{ endfor }}
EOT

say Stache::render(
    $template,
    items => [
        %(
            shape => 'sphere',
            holes => 0,
        ),
        %(
            shape => 'torus',
            holes => 1,
        ),
    ],
);

Output:

shape: sphere
genus: 0

shape: torus
genus: 1

About

Stache is an extensible mustache-style templating engine

Topics

Resources

License

Releases

No releases published

Packages

No packages published

Languages