summaryrefslogtreecommitdiff
path: root/new/lib/crys/renderer.rb
blob: c490330aa2b27e70d46e15557d06675b93bb6e85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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