Class: Lurker::BasePresenter
- Inherits:
-
Object
- Object
- Lurker::BasePresenter
show all
- Defined in:
- lib/lurker/presenters/base_presenter.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ BasePresenter
Returns a new instance of BasePresenter.
8
9
10
|
# File 'lib/lurker/presenters/base_presenter.rb', line 8
def initialize(options = {})
@options = options
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
6
7
8
|
# File 'lib/lurker/presenters/base_presenter.rb', line 6
def options
@options
end
|
Instance Method Details
#css_path ⇒ Object
30
31
32
|
# File 'lib/lurker/presenters/base_presenter.rb', line 30
def css_path
File.join(html_directory, "styles.css")
end
|
#get_binding ⇒ Object
18
19
20
|
# File 'lib/lurker/presenters/base_presenter.rb', line 18
def get_binding
binding
end
|
#html_directory ⇒ Object
22
23
24
|
# File 'lib/lurker/presenters/base_presenter.rb', line 22
def html_directory
options[:url_base_path] || options[:html_directory] || ""
end
|
#index_path(subdirectory = "") ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/lurker/presenters/base_presenter.rb', line 34
def index_path(subdirectory = "")
html_path = File.join(html_directory, subdirectory)
if options[:static_html]
File.join(html_path, 'index.html')
else
html_path
end
end
|
#render(*args) ⇒ Object
54
55
56
|
# File 'lib/lurker/presenters/base_presenter.rb', line 54
def render(*args)
rendering_controller.render_to_string(*args)
end
|
#render_erb(erb_name, binding = get_binding) ⇒ Object
12
13
14
15
16
|
# File 'lib/lurker/presenters/base_presenter.rb', line 12
def render_erb(erb_name, binding = get_binding)
template_path = path_for_template(erb_name)
template = ERB.new(File.read(template_path), nil, '-')
template.result(binding)
end
|
#tag_with_anchor(tag, content, anchor_slug = nil) ⇒ Object
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/lurker/presenters/base_presenter.rb', line 43
def tag_with_anchor(tag, content, anchor_slug = nil)
anchor_slug ||= content.downcase.gsub(' ', '_')
<<-EOS
<#{tag} id="#{anchor_slug}">
<a href="##{anchor_slug}" class="anchor">
#{content}
</a>
</#{tag}>
EOS
end
|
#url_base_path ⇒ Object
26
27
28
|
# File 'lib/lurker/presenters/base_presenter.rb', line 26
def url_base_path
options[:url_base_path] || '/'
end
|