Class: Lutaml::UmlRepository::StaticSite::TemplateFileSystem

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/uml_repository/static_site/generator.rb

Overview

Resolves Liquid include % paths to template files on disk. Unlike LocalFileSystem (which adds a “_” prefix), this resolves paths directly: “components/header” → “<root>/components/header.liquid”

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ TemplateFileSystem

Returns a new instance of TemplateFileSystem.



16
17
18
# File 'lib/lutaml/uml_repository/static_site/generator.rb', line 16

def initialize(root)
  @root = root
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



14
15
16
# File 'lib/lutaml/uml_repository/static_site/generator.rb', line 14

def root
  @root
end

Instance Method Details

#read_template_file(template_path) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/lutaml/uml_repository/static_site/generator.rb', line 20

def read_template_file(template_path)
  full = File.expand_path("#{template_path}.liquid", @root)
  unless full.start_with?(@root)
    raise Liquid::FileSystemError,
          "Illegal template path: #{template_path}"
  end

  File.read(full)
end