Class: Slim::Include Private
- Defined in:
- lib/slim/include.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.
Handles inlined includes
Slim files are compiled, non-Slim files are included as text with #{interpolation}
Instance Method Summary collapse
Methods inherited from Filter
#on_slim_control, #on_slim_embedded, #on_slim_output, #on_slim_text
Instance Method Details
#on_html_tag(tag, attributes, content = nil) ⇒ 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.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/slim/include.rb', line 13 def on_html_tag(tag, attributes, content = nil) return super if tag != 'include' name = content.to_a.flatten.select {|s| String === s }.join raise ArgumentError, 'Invalid include statement' unless attributes == [:html, :attrs] && !name.empty? unless file = find_file(name) name = "#{name}.slim" if name !~ /\.slim\Z/i file = find_file(name) end raise Temple::FilterError, "'#{name}' not found in #{[:include_dirs].join(':')}" unless file content = File.read(file) if file =~ /\.slim\Z/i Thread.current[:slim_include_engine].call(content) else [:slim, :interpolate, content] end end |