Skip to content

Commit

Permalink
0.11.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Polgár Márton committed Mar 8, 2023
1 parent 05d9810 commit e259e08
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -2,6 +2,9 @@ Revision history for Template6

{{$NEXT}}

0.11.3 2023-03-08T01:07:07+01:00
- implementing missing reset flag

0.11.2 2023-03-07T10:26:57+01:00
- do not fall back to bare words in for loops
- missing identifier should result into an empty loop
Expand Down
2 changes: 1 addition & 1 deletion META6.json
Expand Up @@ -31,5 +31,5 @@
],
"test-depends": [
],
"version": "0.11.2"
"version": "0.11.3"
}
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -128,7 +128,7 @@ COPYRIGHT AND LICENSE

Copyright 2012 - 2017 Timothy Totten

Copyright 2018 - 2022 Raku Community
Copyright 2018 - 2023 Raku Community

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

2 changes: 1 addition & 1 deletion lib/Template6.rakumod
Expand Up @@ -115,7 +115,7 @@ Timothy Totten
Copyright 2012 - 2017 Timothy Totten
Copyright 2018 - 2022 Raku Community
Copyright 2018 - 2023 Raku Community
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.
Expand Down
2 changes: 1 addition & 1 deletion lib/Template6/Context.rakumod
Expand Up @@ -7,7 +7,7 @@ use Template6::Provider::String;

has $.service; # The parent Service object.
has $.parser; # Our Parser object.
has $.stash is rw; # Our Stash object.
has $.stash is rw handles <reset>; # Our Stash object.

has %.blocks; # Currently known blocks.
has @.block-cache; # Known block tree (for nested contexts.)
Expand Down
4 changes: 4 additions & 0 deletions lib/Template6/Stash.rakumod
Expand Up @@ -56,4 +56,8 @@ method declone {
$.parent || self
}

method reset {
%!data = Empty;
}

# vim: expandtab shiftwidth=4
57 changes: 57 additions & 0 deletions t/09-reset.rakutest
@@ -0,0 +1,57 @@
use Test;
use Template6;

plan 2;

my $t6-noreset = Template6.new;
$t6-noreset.add-path: 't/templates';
my $t6-reset = Template6.new: :reset;
$t6-reset.add-path: 't/templates';

my @ul = 'First', 'Second', 'Third';
my @ol = 'One', 'Two', 'Three';
# we know the result from 02-for.rakutest and we don't really care here anyway
# it's an organic way to set the stash
$t6-noreset.process('for', :title<For Test>, :@ul, :@ol);
$t6-reset.process('for', :title<For Test>, :@ul, :@ol);


my $wanted-noreset = "<html>
<head>
<title>For Test</title>
</head>
<body>
<ul>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ul>
<ol>
<li>Ain't</li>
<li>Nobody</li>
</ol>
</body>
</html>
";

my $wanted-reset = "<html>
<head>
<title>For Test</title>
</head>
<body>
<ul>
</ul>
<ol>
<li>Ain't</li>
<li>Nobody</li>
</ol>
</body>
</html>
";

@ol = <Ain't Nobody>;
is $t6-noreset.process('for', :title<For Test>, :@ol), $wanted-noreset, 'Unmodified variable stays set.';
is $t6-reset.process('for', :title<For Test>, :@ol), $wanted-reset, 'Unmodified variable gets reset.';


# vim: expandtab shiftwidth=4

0 comments on commit e259e08

Please sign in to comment.