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.



233
234
235
# File 'lib/liquid_ext.rb', line 233

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

Instance Method Details

#read_template_file(name) ⇒ Object



237
238
239
240
241
242
243
244
245
246
# File 'lib/liquid_ext.rb', line 237

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