Class: Haml::Filters::TiltBase

Inherits:
Base
  • Object
show all
Defined in:
lib/haml/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 Haml::Filters::Base

Class Method Details

.render(name, source, indent_width: 0)



7
8
9
10
11
12
13
14
15
# File 'lib/haml/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
  if text.frozen?
    text.gsub(/^/, ' ' * indent_width)
  else
    text.gsub!(/^/, ' ' * indent_width)
  end
end

Instance Method Details

#explicit_require?(needed_registration) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/haml/filters/tilt_base.rb', line 17

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