Class: Relaton::Cli::XmlToHtmlRenderer
- Inherits:
-
Object
- Object
- Relaton::Cli::XmlToHtmlRenderer
- Defined in:
- lib/relaton/cli/xml_to_html_renderer.rb
Class Method Summary collapse
-
.render(file, options) ⇒ Object
Render HTML.
Instance Method Summary collapse
-
#initialize(liquid_dir: nil, stylesheet: nil) ⇒ XmlToHtmlRenderer
constructor
A new instance of XmlToHtmlRenderer.
- #render(index_xml) ⇒ Object
- #uri_for_extension(uri, extension) ⇒ Object
Constructor Details
#initialize(liquid_dir: nil, stylesheet: nil) ⇒ XmlToHtmlRenderer
Returns a new instance of XmlToHtmlRenderer.
7 8 9 10 11 |
# File 'lib/relaton/cli/xml_to_html_renderer.rb', line 7 def initialize(liquid_dir: nil, stylesheet: nil) @liquid_dir = liquid_dir @stylesheet = read_file(stylesheet) init_liquid_template_and_filesystem end |
Class Method Details
.render(file, options) ⇒ Object
Render HTML
This interface allow us to convert a Relaton XML to HTML using the specified liquid template and stylesheets. It also do some minor clean during this conversion.
31 32 33 |
# File 'lib/relaton/cli/xml_to_html_renderer.rb', line 31 def self.render(file, ) new().render(file) end |
Instance Method Details
#render(index_xml) ⇒ Object
13 14 15 16 17 |
# File 'lib/relaton/cli/xml_to_html_renderer.rb', line 13 def render(index_xml) Liquid::Template. parse(template). render(build_liquid_document(index_xml)) end |
#uri_for_extension(uri, extension) ⇒ Object
19 20 21 22 23 |
# File 'lib/relaton/cli/xml_to_html_renderer.rb', line 19 def uri_for_extension(uri, extension) unless uri.nil? uri.sub(/\.[^.]+$/, ".#{extension.to_s}") end end |