erb :foo, :layout => :bar, :escape_html => true
Tilt::ErubisTemplate#prepare modifies the options hash; it merges in
{:preamble => false, :postamble => false}, and
deletes :outvar, :engine_class, and :escape_html keys.
Issue arises when using Sinatra layouts because Sinatra reuses the
same options hash to render the layout after it has rendered the inner
template. The result is: the inner template is rendered
with :escape_html option, but the layout is not.
(Note that if you use Sinatra's set method to set :escape_html
globally, e.g. set :erubis, :escape_html => true, this option will be
merged in for both the layout and the template, so the issue won't
occur.)
Duping the options hash in Tilt::Template#initialize seems to fix
things. I'd be happy to prepare a patch.
Merged a few days ago. I'll get a release out soonish. Sinatra will
pick up the latest installed version of Tilt so that should fix all
the issues people have been having with this.
Thanks,
Ryan
> On Mar 25, 6:15 pm, Geoff Buesing <gbues...@gmail.com> wrote:
>> I came across this issue while trying to render an erubis template in
>> Sinatra with a layout and the new :escape_html => true feature, ex:
>>
>> erb :foo, :layout => :bar, :escape_html => true
>>
>> Tilt::ErubisTemplate#prepare modifies the options hash; it merges in
>> {:preamble => false, :postamble => false}, and
>> deletes :outvar, :engine_class, and :escape_html keys.
>>
>> Issue arises when using Sinatra layouts because Sinatra reuses the
>> same options hash to render the layout after it has rendered the inner
>> template. The result is: the inner template is rendered
>> with :escape_html option, but the layout is not.
>>
>> (Note that if you use Sinatra's set method to set :escape_html
>> globally, e.g. set :erubis, :escape_html => true, this option will be
>> merged in for both the layout and the template, so the issue won't
>> occur.)
>>
>> Duping the options hash in Tilt::Template#initialize seems to fix
>> things. I'd be happy to prepare a patch.
>
>
> --
> To unsubscribe, reply using "remove me" as the subject.
>