Class: Slim::Sections Private

Inherits:
Filter
  • Object
show all
Defined in:
lib/slim/sections.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.

Handle logic-less mode This filter can be activated with the option “sections”

Instance Method Summary collapse

Methods inherited from Filter

#on_slim_condcomment, #on_slim_embedded

Constructor Details

#initialize(opts = {}) ⇒ Sections

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.

Returns a new instance of Sections.



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

def initialize(opts = {})
  super
  unless [:string, :symbol, :wrapped].include?(options[:dictionary_access])
    raise "Invalid dictionary access #{options[:dictionary_access].inspect}"
  end
end

Instance Method Details

#call(exp) ⇒ 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
23
24
25
26
27
28
# File 'lib/slim/sections.rb', line 17

def call(exp)
  if options[:sections]
    # Store the dictionary in the _slimdict variable
    dictionary = options[:dictionary]
    dictionary = "Slim::Wrapper.new(#{dictionary})" if options[:dictionary_access] == :wrapped
    [:multi,
     [:code, "_slimdict = #{dictionary}"],
     super]
  else
    exp
  end
end

#on_code(code) ⇒ 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.



52
53
54
# File 'lib/slim/sections.rb', line 52

def on_code(code)
  raise 'Embedded code is forbidden in sections mode'
end

#on_dynamic(code) ⇒ 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.



48
49
50
# File 'lib/slim/sections.rb', line 48

def on_dynamic(code)
  raise 'Embedded code is forbidden in sections mode'
end

#on_slim_attr(name, escape, value) ⇒ 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.



44
45
46
# File 'lib/slim/sections.rb', line 44

def on_slim_attr(name, escape, value)
  [:slim, :attr, name, escape, access(value)]
end

#on_slim_control(name, content) ⇒ 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.

Interpret control blocks as sections or inverted sections



31
32
33
34
35
36
37
# File 'lib/slim/sections.rb', line 31

def on_slim_control(name, content)
  if name =~ /\A!\s*(.*)/
    on_slim_inverted_section($1, content)
  else
    on_slim_section(name, content)
  end
end

#on_slim_output(escape, name, content) ⇒ 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.



39
40
41
42
# File 'lib/slim/sections.rb', line 39

def on_slim_output(escape, name, content)
  raise 'Output statements with content are forbidden in sections mode' if !empty_exp?(content)
  [:slim, :output, escape, access(name), content]
end