typester (owner)

Revisions

gist: 160340 Download_button fork
public
Public Clone URL: git://gist.github.com/160340.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
diff --git a/lib/Text/MicroTemplate.pm b/lib/Text/MicroTemplate.pm
index 2f00f51..bbfdd62 100644
--- a/lib/Text/MicroTemplate.pm
+++ b/lib/Text/MicroTemplate.pm
@@ -393,6 +393,8 @@ package Text::MicroTemplate::EncodedString;
 use strict;
 use warnings;
 
+use overload q{""} => sub { shift->as_string }, fallback => 1;
+
 sub new {
     my ($klass, $str) = @_;
     bless \$str, $klass;
diff --git a/t/03-modes.t b/t/03-modes.t
index 0bb1987..ea71038 100644
--- a/t/03-modes.t
+++ b/t/03-modes.t
@@ -1,6 +1,6 @@
 use strict;
 use warnings;
-use Test::More tests => 6;
+use Test::More tests => 8;
 use Text::MicroTemplate qw(:all);
 
 # comment
@@ -17,6 +17,10 @@ do {
     is render_mt('<?= $_[0] ?>', 'foo<a')->as_string, 'foo&lt;a';
     my $rs = encoded_string('foo<a');
     is render_mt('<?= $_[0] ?>', $rs)->as_string, 'foo<a';
+
+ # overload
+ is $rs, 'foo<a';
+ is render_mt('<?= $_[0] ?>', $rs), 'foo<a';
 };
 do {
     use utf8;