bridgetownrb/bridgetown

Possible Tilt rendering optimization

Closed this issue · 0 comments

In various experiments with SSR—but this could apply even to layouts in static rendering—I got to thinking that we should try caching Tilt template instances across resource transformations. I believe what's happening now is every single converter (ERB, Serbea, etc.) is having to compile the template for each conversion. This is slower than having a precompiled template available to use.

erb_renderer = Tilt::ErubiTemplate.new(

Here, instead of instantiating a new template no matter what, we should check a template cache first. We're actually already doing this with partials, see:

tmpl.template ||= Tilt::ErubiTemplate.new(