Class: TRMNL::Liquid::MemorySystem

Inherits:
Liquid::BlankFileSystem
  • Object
show all
Defined in:
lib/trmnl/liquid/memory_system.rb

Overview

An in-memory file system for storing custom templates defined with template [name] % tags.

Instance Method Summary collapse

Constructor Details

#initializeMemorySystem

Returns a new instance of MemorySystem.



7
8
9
10
# File 'lib/trmnl/liquid/memory_system.rb', line 7

def initialize
  super
  @templates = {}
end

Instance Method Details

#read_template_file(name) ⇒ Object



16
17
18
# File 'lib/trmnl/liquid/memory_system.rb', line 16

def read_template_file name
  templates[name] || fail(::Liquid::FileSystemError, "Template not found: #{name}.")
end

#register(name, body) ⇒ Object



12
13
14
# File 'lib/trmnl/liquid/memory_system.rb', line 12

def register name, body
  templates[name] = body
end