Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Template/Stash.pm
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ sub _dotop {
}
# ugly hack: only allow import vmeth to be called on root stash
elsif (($value = $HASH_OPS->{ $item })
&& ! $atroot || $item eq 'import') {
&& (! $atroot || $item eq 'import')) {
@result = &$value($root, @$args); ## @result
}
elsif ( ref $item eq 'ARRAY' ) {
Expand Down
13 changes: 13 additions & 0 deletions t/stash.t
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,16 @@ PASS: stringified from GetNumbersome
[% cmp_ol.hello %]
-- expect --
Hello

# Verify that hash vmethods (e.g. keys, size) work on non-root hashes
# and that 'import' works on root stash (operator precedence fix)

-- test --
[% myhash = { a => 1, b => 2 }; myhash.keys.sort.join(', ') %]
-- expect --
a, b

-- test --
[% myhash = { x => 10 }; CALL myhash.import({ y => 20 }); myhash.keys.sort.join(', ') %]
-- expect --
x, y