Handle logic less mode This filter can be activated with the option “logic_less” @api private
Default dictionary access order, change it with the option :dictionary_access
# File lib/slim/logic_less/filter.rb, line 13 def initialize(opts = {}) super access = [options[:dictionary_access]].flatten.compact access.each do |type| raise ArgumentError, "Invalid dictionary access #{type.inspect}" unless DEFAULT_ACCESS_ORDER.include?(type) end raise ArgumentError, 'Option dictionary access is missing' if access.empty? @access = access.inspect end
# File lib/slim/logic_less/filter.rb, line 23 def call(exp) if options[:logic_less] @context = unique_name [:multi, [:code, "#{@context} = ::Slim::LogicLess::Context.new(#{options[:dictionary]}, #{@access})"], super] else exp end end
# File lib/slim/logic_less/filter.rb, line 63 def on_code(code) raise Temple::FilterError, 'Embedded code is forbidden in logic less mode' end
# File lib/slim/logic_less/filter.rb, line 59 def on_dynamic(code) raise Temple::FilterError, 'Embedded code is forbidden in logic less mode' end
# File lib/slim/logic_less/filter.rb, line 51 def on_slim_attrvalue(escape, value) [:slim, :attrvalue, escape, access(value)] end
Interpret control blocks as sections or inverted sections
# File lib/slim/logic_less/filter.rb, line 35 def on_slim_control(name, content) method = if name =~ /\A!\s*(.*)/ name = $1 'inverted_section' else 'section' end [:block, "#{@context}.#{method}(#{name.to_sym.inspect}) do", compile(content)] end
Generated with the Darkfish Rdoc Generator 2.