Class: Octodown::Renderer::HTML
- Inherits:
-
Object
- Object
- Octodown::Renderer::HTML
- Includes:
- Renderable, Support
- Defined in:
- lib/octodown/renderer/html.rb
Instance Attribute Summary collapse
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#rendered_markdown ⇒ Object
readonly
Returns the value of attribute rendered_markdown.
Instance Method Summary collapse
- #content ⇒ Object
- #highlight_stylesheet ⇒ Object
- #host ⇒ Object
-
#initialize(rendered_markdown, options = {}) ⇒ HTML
constructor
A new instance of HTML.
- #present ⇒ Object
- #stylesheet ⇒ Object
- #title ⇒ Object
Methods included from Renderable
Constructor Details
#initialize(rendered_markdown, options = {}) ⇒ HTML
Returns a new instance of HTML.
14 15 16 17 18 19 |
# File 'lib/octodown/renderer/html.rb', line 14 def initialize(rendered_markdown, = {}) @logger = [:logger] @rendered_markdown = rendered_markdown @options = @filepath = File.join parent_dir, 'template', 'octodown.html.erb' end |
Instance Attribute Details
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
12 13 14 |
# File 'lib/octodown/renderer/html.rb', line 12 def filepath @filepath end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/octodown/renderer/html.rb', line 12 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/octodown/renderer/html.rb', line 12 def @options end |
#rendered_markdown ⇒ Object (readonly)
Returns the value of attribute rendered_markdown.
12 13 14 |
# File 'lib/octodown/renderer/html.rb', line 12 def rendered_markdown @rendered_markdown end |
Instance Method Details
#content ⇒ Object
21 22 23 24 25 |
# File 'lib/octodown/renderer/html.rb', line 21 def content template_text = File.read filepath erb_template = ERB.new template_text erb_template.result binding end |
#highlight_stylesheet ⇒ Object
36 37 38 |
# File 'lib/octodown/renderer/html.rb', line 36 def highlight_stylesheet inject_html_node_with_file_content assets_dir('highlight.css'), :style end |
#host ⇒ Object
40 41 42 |
# File 'lib/octodown/renderer/html.rb', line 40 def host "ws://localhost:#{[:port]}".dump end |
#present ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/octodown/renderer/html.rb', line 44 def present if [:no_open] logger.warn('--no-open argument was used so no browser will be opened') else Launchy.open PersistentTempfile.create(content, :html).path end end |
#stylesheet ⇒ Object
31 32 33 34 |
# File 'lib/octodown/renderer/html.rb', line 31 def stylesheet stylesheet = "#{[:style]}.css" inject_html_node_with_file_content assets_dir(stylesheet), :style end |
#title ⇒ Object
27 28 29 |
# File 'lib/octodown/renderer/html.rb', line 27 def title 'Octodown Preview' end |