Class: Coradoc::Html::Theme::Base Abstract
- Inherits:
-
Object
- Object
- Coradoc::Html::Theme::Base
- Defined in:
- lib/coradoc/html/theme/base.rb
Overview
Subclass and implement #render to create a custom theme
Abstract base class for all HTML themes
This class defines the interface that all theme renderers must implement. Themes are responsible for converting Coradoc document models to HTML output.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(document, options = {}) ⇒ Base
constructor
Initialize a new theme instance.
-
#render ⇒ String
abstract
Render the document to HTML.
-
#render_html5 ⇒ String
Render the complete HTML5 document.
-
#supported_features ⇒ Array<Symbol>
List of features supported by this theme.
-
#supports?(feature) ⇒ Boolean
Check if this theme supports a specific feature.
-
#theme_name ⇒ Symbol
Get the theme name.
Constructor Details
#initialize(document, options = {}) ⇒ Base
Initialize a new theme instance
21 22 23 24 |
# File 'lib/coradoc/html/theme/base.rb', line 21 def initialize(document, = {}) @document = document @options = end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
15 16 17 |
# File 'lib/coradoc/html/theme/base.rb', line 15 def document @document end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/coradoc/html/theme/base.rb', line 15 def @options end |
Instance Method Details
#render ⇒ String
Render the document to HTML
This method must be implemented by subclasses.
32 33 34 35 |
# File 'lib/coradoc/html/theme/base.rb', line 32 def render raise NotImplementedError, "#{self.class.name} must implement #render method" end |
#render_html5 ⇒ String
Render the complete HTML5 document
40 41 42 43 |
# File 'lib/coradoc/html/theme/base.rb', line 40 def render_html5 html_body = render build_html5_document(html_body) end |
#supported_features ⇒ Array<Symbol>
List of features supported by this theme
Subclasses can override to declare supported features.
68 69 70 |
# File 'lib/coradoc/html/theme/base.rb', line 68 def supported_features [] end |
#supports?(feature) ⇒ Boolean
Check if this theme supports a specific feature
59 60 61 |
# File 'lib/coradoc/html/theme/base.rb', line 59 def supports?(feature) supported_features.include?(feature) end |
#theme_name ⇒ Symbol
Get the theme name
48 49 50 51 52 53 |
# File 'lib/coradoc/html/theme/base.rb', line 48 def theme_name @theme_name ||= self.class.name.split('::').last .gsub(/Renderer$/, '') .downcase .to_sym end |