MojoliciousをアップデートしたらMojo::Templateでエラーが出るようになった
昨日書いたKobitoViewerを動かしているサーバのMojoliciousを最新(v2.92)にアップデートしたらエラーが出て動かなくなった。
Undefined subroutine &Mojo::Template::SandBox::f08af35edfb6fff00e16521ce13bfb68::b called at template from DATA section "index.html.ep"
どうも <%= b($md) => と書いていたところで引っ掛かっている様子。
perldocを見てみる
Automatic escaping Escaping behavior can be reversed with the "auto_escape" attribute, this is the default in Mojolicious ".ep" templates for example. <%= Perl expression, replaced with XML escaped result %> <%== Perl expression, replaced with result %> Mojo::ByteStream objects are always excluded from automatic escaping. <%= Mojo::ByteStream->new('<div>excluded!</div>') %>
あれ、数日前に調べたときと違う気が・・・
こんなときはmetacpanでdiff
@@ -430,7 +422,7 @@ the default in L<Mojolicious> C<.ep> templates for example. L<Mojo::ByteStream> objects are always excluded from automatic escaping. - <%= b('<div>excluded!</div>') %> + <%= Mojo::ByteStream->new('<div>excluded!</div>') %> =head2 Trimming
やっぱり使い方が変わったらしい。
とりあえずpod通りに修正したら無事動くようになったけど、テンプレートの中で ->new するのはさすがに気持ち悪い気がするのは僕だけかな。。