Class: PrettyDoc::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/pretty_doc/template.rb

Overview

Base Template class

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dirObject

Returns the value of attribute dir.



7
8
9
# File 'lib/pretty_doc/template.rb', line 7

def dir
  @dir
end

Class Method Details

.get(name) ⇒ Object



15
16
17
18
# File 'lib/pretty_doc/template.rb', line 15

def get(name)
  @pool ||= {}
  @pool[name]
end

.register(name, theme) ⇒ Object



10
11
12
13
# File 'lib/pretty_doc/template.rb', line 10

def register(name, theme)
  @pool ||= {}
  @pool[name] = theme
end

Instance Method Details

#assetsObject



25
26
27
# File 'lib/pretty_doc/template.rb', line 25

def assets
  [Resource::Scss.new(dir)]
end

#render(hash) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/pretty_doc/template.rb', line 29

def render(hash)
  erb_file = theme_file_pathname('template.html.erb')
  template = ERB.new(erb_file.read)

  @content = hash[:content]
  @title = hash[:title]
  template.result(binding)
end

#theme_file_pathname(file) ⇒ Object



21
22
23
# File 'lib/pretty_doc/template.rb', line 21

def theme_file_pathname(file)
  dir.join(file)
end

#write_assets(dir) ⇒ Object



38
39
40
41
42
# File 'lib/pretty_doc/template.rb', line 38

def write_assets(dir)
  assets.each do |asset|
    asset.write(dir)
  end
end