Class: Markup::InlineTemplatesFileSystem

Inherits:
Liquid::BlankFileSystem
  • Object
show all
Defined in:
lib/markup/inline_templates_file_system.rb

Overview

This in-memory “file system” is the backing storage for custom templates defined template [name] % tags.

Instance Method Summary collapse

Constructor Details

#initializeInlineTemplatesFileSystem

Returns a new instance of InlineTemplatesFileSystem.



4
5
6
7
# File 'lib/markup/inline_templates_file_system.rb', line 4

def initialize
  super
  @templates = {}
end

Instance Method Details

#read_template_file(name) ⇒ Object

called by Liquid::Template for render ‘foo’ % when rendering screen markup



15
16
17
# File 'lib/markup/inline_templates_file_system.rb', line 15

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

#register(name, body) ⇒ Object

called by Markup::LiquidTemplateTag to save users’ custom shared templates via our custom template % tag



10
11
12
# File 'lib/markup/inline_templates_file_system.rb', line 10

def register(name, body)
  @templates[name] = body
end