Sha256: c92af49256503bf508544270a1c58d9c66c0400afab3ee5aaa27d760cd7bb383

Contents?: true

Size: 1019 Bytes

Versions: 14

Compression:

Stored size: 1019 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, :line_numbers => true)
        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

      def warnings
        @template.warnings
      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

14 entries across 14 versions & 1 rubygems

Version Path
jekyll-3.5.2 lib/jekyll/liquid_renderer/file.rb
jekyll-3.5.1 lib/jekyll/liquid_renderer/file.rb
jekyll-3.4.5 lib/jekyll/liquid_renderer/file.rb
jekyll-3.5.0 lib/jekyll/liquid_renderer/file.rb
jekyll-3.4.4 lib/jekyll/liquid_renderer/file.rb
jekyll-3.4.3 lib/jekyll/liquid_renderer/file.rb
jekyll-3.4.2 lib/jekyll/liquid_renderer/file.rb
jekyll-3.4.1 lib/jekyll/liquid_renderer/file.rb
jekyll-3.4.0 lib/jekyll/liquid_renderer/file.rb
jekyll-3.3.1 lib/jekyll/liquid_renderer/file.rb
jekyll-3.3.0 lib/jekyll/liquid_renderer/file.rb
jekyll-3.3.0.pre.rc1 lib/jekyll/liquid_renderer/file.rb
jekyll-3.2.1 lib/jekyll/liquid_renderer/file.rb
jekyll-3.2.0 lib/jekyll/liquid_renderer/file.rb