Permalink
Browse files

Don't export variables with special symbols

  • Loading branch information...
1 parent 24ad159 commit 36636e98be6c9a52d3aa1bb838f53658d9563577 @vti committed Feb 8, 2010
Showing with 12 additions and 3 deletions.
  1. +2 −1 lib/Text/Haml.pm
  2. +10 −2 t/perl.t
View
3 lib/Text/Haml.pm
@@ -7,7 +7,7 @@ use IO::File;
use Scalar::Util qw/weaken/;
use Encode qw/decode/;
-our $VERSION = '0.990102';
+our $VERSION = '0.990103';
use constant CHUNK_SIZE => 4096;
@@ -529,6 +529,7 @@ EOF
# Install variables
foreach my $var (sort keys %vars) {
+ next unless $var =~ m/^\w+$/;
if ($self->vars_as_subs) {
next if $self->helpers->{$var};
$code
View
12 t/perl.t
@@ -5,7 +5,7 @@ use warnings;
use Text::Haml;
-use Test::More tests => 9;
+use Test::More tests => 10;
my $haml = Text::Haml->new;
@@ -96,7 +96,7 @@ is($output, <<'EOF');
</p>
EOF
-# Inserting variables without a $
+# Inserting variables
$output = $haml->render(<<'EOF', foo => 1, bar => 2);
= $foo + $bar
- $foo = 2;
@@ -106,3 +106,11 @@ is($output, <<'EOF');
3
2
EOF
+
+# Inserting variables with special symbols
+$output = $haml->render(<<'EOF', 'foo.bar' => 1);
+Nothing is exported
+EOF
+is($output, <<'EOF');
+Nothing is exported
+EOF

0 comments on commit 36636e9

Please sign in to comment.