Class: Hamlit::Filters::TiltBase

Inherits:
Base show all
Defined in:
lib/hamlit/filters/tilt_base.rb

Direct Known Subclasses

Coffee, Erb, Less, Markdown, Sass, Scss

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Hamlit::Filters::Base

Class Method Details

.render(name, source, indent_width: 0) ⇒ Object


7
8
9
10
11
# File 'lib/hamlit/filters/tilt_base.rb', line 7

def self.render(name, source, indent_width: 0)
  text = ::Tilt["t.#{name}"].new { source }.render
  return text if indent_width == 0
  text.gsub!(/^/, ' ' * indent_width)
end

Instance Method Details

#explicit_require?(needed_registration) ⇒ Boolean

Returns:

  • (Boolean)

13
14
15
16
# File 'lib/hamlit/filters/tilt_base.rb', line 13

def explicit_require?(needed_registration)
  Gem::Version.new(Tilt::VERSION) >= Gem::Version.new('2.0.0') &&
    !Tilt.registered?(needed_registration)
end