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.
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) ⇒ 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.
34 35 36 |
# File 'lib/relaton/cli/xml_to_html_renderer.rb', line 34 def self.render(file, ) new().render(file) end |
Instance Method Details
#render(index_xml) ⇒ String
Returns HTML.
15 16 17 18 19 |
# File 'lib/relaton/cli/xml_to_html_renderer.rb', line 15 def render(index_xml) Liquid::Template .parse(template) .render(build_liquid_document(index_xml)) end |
#uri_for_extension(uri, extension) ⇒ Object
21 22 23 |
# File 'lib/relaton/cli/xml_to_html_renderer.rb', line 21 def uri_for_extension(uri, extension) uri&.sub(/\.[^.]+$/, ".#{extension}") end |