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.



20
21
22
# File 'lib/lutaml/uml_repository/static_site/generator.rb', line 20

def initialize(root)
  @root = root
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



18
19
20
# File 'lib/lutaml/uml_repository/static_site/generator.rb', line 18

def root
  @root
end

Instance Method Details

#read_template_file(template_path) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/lutaml/uml_repository/static_site/generator.rb', line 24

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