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) ⇒ String
Render HTML.
Instance Method Summary collapse
-
#initialize(liquid_dir: nil, stylesheet: nil) ⇒ XmlToHtmlRenderer
constructor
A new instance of XmlToHtmlRenderer.
-
#render(index_xml) ⇒ String
HTML.
- #uri_for_extension(uri, extension) ⇒ Object
Constructor Details
#initialize(liquid_dir: nil, stylesheet: nil) ⇒ XmlToHtmlRenderer
Returns a new instance of XmlToHtmlRenderer.
6 7 8 9 10 |
# File 'lib/relaton/cli/xml_to_html_renderer.rb', line 6 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) ⇒ String
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.
33 34 35 |
# File 'lib/relaton/cli/xml_to_html_renderer.rb', line 33 def self.render(file, ) new(**).render(file) end |
Instance Method Details
#render(index_xml) ⇒ String
Returns HTML.
14 15 16 17 18 |
# File 'lib/relaton/cli/xml_to_html_renderer.rb', line 14 def render(index_xml) Liquid::Template .parse(template) .render(build_liquid_document(index_xml)) end |
#uri_for_extension(uri, extension) ⇒ Object
20 21 22 |
# File 'lib/relaton/cli/xml_to_html_renderer.rb', line 20 def uri_for_extension(uri, extension) uri&.sub(/\.[^.]+$/, ".#{extension}") end |