Sha256: 14081e2544450730f72163a84a1ec4adb5dbd5caebe864ab58046623ed16fb0f

Contents?: true

Size: 959 Bytes

Versions: 14

Compression:

Stored size: 959 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

      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 & 3 rubygems

Version Path
blackboard-3.1.9 lib/jekyll/liquid_renderer/file.rb
blackboard-3.1.8 lib/jekyll/liquid_renderer/file.rb
blackboard-3.1.7 lib/jekyll/liquid_renderer/file.rb
jekyll-3.2.0.pre.beta1 lib/jekyll/liquid_renderer/file.rb
jekyll-3.1.6 lib/jekyll/liquid_renderer/file.rb
jekyll-3.1.5 lib/jekyll/liquid_renderer/file.rb
jekyll-3.1.4 lib/jekyll/liquid_renderer/file.rb
jekyll-3.0.5 lib/jekyll/liquid_renderer/file.rb
jekyll-3.1.3 lib/jekyll/liquid_renderer/file.rb
jekyll-3.0.4 lib/jekyll/liquid_renderer/file.rb
jekyll-3.1.2 lib/jekyll/liquid_renderer/file.rb
jekyllplusadmin-1.1.0 lib/jekyll/liquid_renderer/file.rb
jekyllplusadmin-1.0.0 lib/jekyll/liquid_renderer/file.rb
jekyll-3.0.3 lib/jekyll/liquid_renderer/file.rb