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, InterpolateTiltEngine, PrecompiledTiltEngine, RubyEngine, SassEngine, StaticTiltEngine, TagEngine, TiltEngine

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Filter

#on_slim_attrs, #on_slim_condcomment, #on_slim_control, #on_slim_output, #on_slim_tag

Class Attribute Details

.enginesObject (readonly)

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.



67
68
69
# File 'lib/slim/embedded_engine.rb', line 67

def engines
  @engines
end

Class Method Details

.register(name, klass, *option_filter) ⇒ 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.

Register embedded engine

Parameters:

  • name (String)

    Name of the engine

  • klass (Class)

    Engine class

  • option_filter

    List of options to pass to engine. Last argument can be default option hash.



75
76
77
78
# File 'lib/slim/embedded_engine.rb', line 75

def register(name, klass, *option_filter)
  local_options = Hash === option_filter.last ? option_filter.pop : nil
  @engines[name.to_s] = [klass, option_filter, local_options]
end

Instance Method Details

#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.



81
82
83
84
85
86
87
88
# File 'lib/slim/embedded_engine.rb', line 81

def on_slim_embedded(name, body)
  name = name.to_s
  raise "Embedded engine #{name} is disabled" if (options[:enable_engines] && !options[:enable_engines].include?(name)) ||
                                                 (options[:disable_engines] && options[:disable_engines].include?(name))
  engine, option_filter, local_options = self.class.engines[name] || raise("Embedded engine #{name} not found")
  filtered_options = Hash[*option_filter.select {|k| options.include?(k) }.map {|k| [k, options[k]] }.flatten]
  engine.new(Temple::ImmutableHash.new(local_options, filtered_options)).on_slim_embedded(name, body)
end