Class: Slim::EmbeddedEngine Private

Inherits:
Filter
  • Object
show all
Defined in:
lib/slim/embedded_engine.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Temple filter which processes embedded engines

Direct Known Subclasses

ERBEngine, RubyEngine, TagEngine, TiltEngine

Defined Under Namespace

Classes: ERBEngine, RubyEngine, TagEngine, TiltEngine

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Filter

#on_slim_attrs, #on_slim_comment, #on_slim_control, #on_slim_output, #on_slim_tag, #tmp_var

Class Method Details

.[](name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
14
15
# File 'lib/slim/embedded_engine.rb', line 11

def self.[](name)
  engine = @engines[name.to_s]
  raise "Invalid embedded engine #{name}" if !engine
  engine.dup
end

.register(name, klass, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
# File 'lib/slim/embedded_engine.rb', line 7

def self.register(name, klass, options = {})
  @engines[name.to_s] = klass.new(options)
end

Instance Method Details

#collect_text(body) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
29
# File 'lib/slim/embedded_engine.rb', line 24

def collect_text(body)
  body.inject('') do |text, exp|
    text << exp[2] if exp[0] == :slim && exp[1] == :text
    text
  end
end

#on_slim_embedded(name, *body) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
20
21
22
# File 'lib/slim/embedded_engine.rb', line 17

def on_slim_embedded(name, *body)
  engine = EmbeddedEngine[name]
  raise "Embedded engine #{name} is disabled" if (options[:enable_engines] && !options[:enable_engines].include?(name)) ||
                                                 (options[:disable_engines] && options[:disable_engines].include?(name))
  engine.on_slim_embedded(name, *body)
end