diff --git a/lib/Template6/Context.pm6 b/lib/Template6/Context.pm6 index 9a36770..4782072 100644 --- a/lib/Template6/Context.pm6 +++ b/lib/Template6/Context.pm6 @@ -24,7 +24,7 @@ has %.providers; ## Providers for templates, based on prefix names. submethod BUILD (*%args) { $!service = %args; - if (!%args.exists('context')) { + unless %args :exists { %args = self; } if (%args) { @@ -49,13 +49,13 @@ method add-provider ($name, $object) { ## A couple of helper methods for the default provider. method add-path ($path) { - if %!providers.exists('file') { + if %!providers :exists { %!providers.add-path($path); } } method set-extension ($ext) { - if %!providers.exists('file') { + if %!providers :exists { %!providers.ext = $ext; } } @@ -67,7 +67,7 @@ method get-template-text ($name is copy) { $prefix = $0; } - if $prefix.defined && %!providers.exists{$prefix} { + if $prefix.defined && (%!providers{$prefix} :exists) { @providers = %!providers{$prefix}; } else { @@ -82,11 +82,11 @@ method get-template-text ($name is copy) { } method get-template-block ($name) { - if %.blocks.exists($name) { + if %.blocks{$name} :exists { return %.blocks{$name}; } for @.block-cache -> $known-blocks { - if $known-blocks.exists($name) { + if $known-blocks{$name} :exists { return $known-blocks{$name}; } } diff --git a/lib/Template6/Parser.pm6 b/lib/Template6/Parser.pm6 index 0a2af00..b16aa7f 100644 --- a/lib/Template6/Parser.pm6 +++ b/lib/Template6/Parser.pm6 @@ -193,7 +193,7 @@ method compile ($template) { } $script ~= "return \$output;\n\}"; # $*ERR.say: "\n$script\n"; - my $function = eval $script; + my $function = EVAL $script; return $function; } diff --git a/lib/Template6/Provider/File.pm6 b/lib/Template6/Provider/File.pm6 index 903ffa9..414a240 100644 --- a/lib/Template6/Provider/File.pm6 +++ b/lib/Template6/Provider/File.pm6 @@ -20,7 +20,7 @@ method add-path ($path) { } method fetch ($name) { - if %.templates.exists($name) { + if %.templates{$name} :exists { return %.templates{$name}; } for @.include-path -> $path { diff --git a/lib/Template6/Service.pm6 b/lib/Template6/Service.pm6 index b929ada..84795db 100644 --- a/lib/Template6/Service.pm6 +++ b/lib/Template6/Service.pm6 @@ -15,12 +15,12 @@ submethod BUILD (*%args) { $!context = %args; } else { - if (!%args.exists('service')) { + unless %args :exists { %args = self; } $!context = Template6::Context.new(|%args); } - if %args.exists('reset') { + if %args :exists { $!reset = %args; } } diff --git a/lib/Template6/Stash.pm6 b/lib/Template6/Stash.pm6 index 0714dce..f3a4dcd 100644 --- a/lib/Template6/Stash.pm6 +++ b/lib/Template6/Stash.pm6 @@ -13,7 +13,7 @@ method lookup (@query is rw, $data) { my $element = @query.shift; my $found; if $data ~~ Hash { - if $data.exists($element) { + if $data{$element} :exists { $found = $data{$element}; } } @@ -37,7 +37,7 @@ method lookup (@query is rw, $data) { } method get ($query, :$strict) { - if %!data.exists($query) { + if %!data{$query} :exists { return %!data{$query}; } elsif ($query ~~ /\./) { diff --git a/t/02-for.t b/t/02-for.t index b70302e..6f1f12a 100644 --- a/t/02-for.t +++ b/t/02-for.t @@ -61,12 +61,12 @@ $wanted = " "; -my %users = -{ +my %users = %( + 'bob@smith.com' => 27, 'lisa@abbot.org' => 18, 'melissa@senstry.com' => 31, -}; +); is $t6.process('for-hash', :title, :users(%users)), $wanted, 'For statement with hash.';