From d3316d0b042ffa550ff56ed4e691c80003dd1414 Mon Sep 17 00:00:00 2001 From: mms Date: Fri, 27 Dec 2024 00:16:14 +0100 Subject: feat(new): server mode --- new/lib/crys/renderer.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 new/lib/crys/renderer.rb (limited to 'new/lib/crys/renderer.rb') diff --git a/new/lib/crys/renderer.rb b/new/lib/crys/renderer.rb new file mode 100644 index 0000000..c490330 --- /dev/null +++ b/new/lib/crys/renderer.rb @@ -0,0 +1,32 @@ +require 'erb' +require 'pry' + +module Crys + module Splash + class Theme + PARENT_DIR = File.expand_path(".", Dir.pwd) + + def render + template = ERB.new(File.read(PARENT_DIR + "/theme/" + self.class::PAGE)) + template.result(local_binding) + end + + def body + self.class::BODY.result(local_binding) + end + + private + + attr_accessor :template, :data + + def local_binding + local_binding = binding.clone + self.class::DATA.each do |k, v| + local_binding.local_variable_set(k,v) + end + local_binding + + end + end + end +end -- cgit v1.2.3