Sha256: 42a3a27b7a241486eec5320e4cfaef0ba5fff5ae3a68707ed9f66c209ba67c62

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

require 'jekyll-slim/slim_context'

module Jekyll
  class Site

    attr_reader :slim_context

    # Patch to allow usage of site variable in Slim/Haml
    # https://blog.darmasoft.net/2012/02/29/haml-processing-in-jekyll.html
    # https://github.com/mojombo/jekyll/blob/master/lib/jekyll/site.rb
    def instantiate_subclasses(klass)
      klass.subclasses.select do |c|
        !self.safe || c.safe
      end.sort.map do |c|
        conv = c.new(self.config)
        # XXX: Hotfix to allow access site variable in slim/haml templates
        if conv.respond_to?(:locals)
          @slim_context ||= SlimContext.new(self)
          conv.locals({ slim_context: @slim_context })
        end

        conv
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-slim-0.9.1 lib/jekyll-slim/extensions/site.rb
jekyll-slim-0.9.0 lib/jekyll-slim/extensions/site.rb