Sha256: c3f8f697fb4df332bf5f0f6b6d1cb995ea15a5fb98156ee2f539c6529c38af0e

Contents?: true

Size: 939 Bytes

Versions: 13

Compression:

Stored size: 939 Bytes

Contents

module Jekyll
  class LiquidRenderer
    class File
      def initialize(renderer, filename)
        @renderer = renderer
        @filename = filename
      end

      def parse(content)
        measure_time do
          @template = Liquid::Template.parse(content)
        end

        self
      end

      def render(*args)
        measure_time do
          measure_bytes do
            @template.render(*args)
          end
        end
      end

      def render!(*args)
        measure_time do
          measure_bytes do
            @template.render!(*args)
          end
        end
      end

      private

      def measure_bytes
        yield.tap do |str|
          @renderer.increment_bytes(@filename, str.bytesize)
        end
      end

      def measure_time
        before = Time.now
        yield
      ensure
        after = Time.now
        @renderer.increment_time(@filename, after - before)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
jekyll-3.1.1 lib/jekyll/liquid_renderer/file.rb
jekyll-3.1.0 lib/jekyll/liquid_renderer/file.rb
jekyll-3.1.0.pre.rc3 lib/jekyll/liquid_renderer/file.rb
jekyll-3.0.2 lib/jekyll/liquid_renderer/file.rb
jekyll-3.1.0.pre.rc2 lib/jekyll/liquid_renderer/file.rb
jekyll-3.1.0.pre.rc1 lib/jekyll/liquid_renderer/file.rb
jekyll-3.1.0.pre.beta1 lib/jekyll/liquid_renderer/file.rb
jekyll-3.0.1 lib/jekyll/liquid_renderer/file.rb
jekyll-3.0.0 lib/jekyll/liquid_renderer/file.rb
jekyll-3.0.0.pre.rc1 lib/jekyll/liquid_renderer/file.rb
jekyll-3.0.0.pre.beta10 lib/jekyll/liquid_renderer/file.rb
jekyll-3.0.0.pre.beta9 lib/jekyll/liquid_renderer/file.rb
jekyll-3.0.0.pre.beta8 lib/jekyll/liquid_renderer/file.rb