Class: Glim::LocalFileSystem

Inherits:
Object
  • Object
show all
Defined in:
lib/liquid_ext.rb

Instance Method Summary collapse

Constructor Details

#initialize(*paths) ⇒ LocalFileSystem

Returns a new instance of LocalFileSystem.



229
230
231
# File 'lib/liquid_ext.rb', line 229

def initialize(*paths)
  @paths = paths.reject { |path| path.nil? }
end

Instance Method Details

#read_template_file(name) ⇒ Object



233
234
235
236
237
238
239
240
241
242
# File 'lib/liquid_ext.rb', line 233

def read_template_file(name)
  @cache ||= {}
  unless @cache[name]
    paths = @paths.map { |path| File.join(path, name) }
    if file = paths.find { |path| File.exist?(path) }
      @cache[name] = Glim.preprocess_template(File.read(file))
    end
  end
  @cache[name]
end