diff --git a/dcc.gemspec b/dcc.gemspec
index 171f3d8..03d42e1 100644
--- a/dcc.gemspec
+++ b/dcc.gemspec
@@ -38,5 +38,6 @@ Gem::Specification.new do |spec|
spec.add_dependency "lutaml-model", "~> 0.8"
spec.add_dependency "moxml", "~> 0.1.26"
spec.add_dependency "mml", "~> 2.4.0"
+ spec.add_dependency "liquid"
spec.add_dependency "thor"
end
diff --git a/lib/dcc/cli/cli.rb b/lib/dcc/cli/cli.rb
index 73a51bf..7544c39 100644
--- a/lib/dcc/cli/cli.rb
+++ b/lib/dcc/cli/cli.rb
@@ -69,6 +69,7 @@ def convert(format, file)
case format
when "json" then ::Dcc::Convert::Json.call(dcc)
when "yaml" then ::Dcc::Convert::Yaml.call(dcc)
+ when "html" then ::Dcc::Convert::Html.call(dcc)
else
abort "Format not yet implemented: #{format}"
end
diff --git a/lib/dcc/convert/html.rb b/lib/dcc/convert/html.rb
index 4eb9b50..bb66b7e 100644
--- a/lib/dcc/convert/html.rb
+++ b/lib/dcc/convert/html.rb
@@ -1,42 +1,19 @@
# frozen_string_literal: true
+require "liquid"
+
module Dcc
module Convert
- # `Dcc::Convert::Html` renders a parsed DCC into a human-readable HTML
- # report with collapsible sections per administrative section and
- # measurement result.
module Html
- class << self
- # @param dcc [Lutaml::Model::Serializable]
- # @return [Dcc::Convert::Result]
- def call(dcc)
- payload = <<~HTML
-
-
-
-
+
+ {% assign admin = dcc.adminativeData %}
+ {% assign core = dcc.administrativeData.coreData %}
+ {% assign items = dcc.administrativeData.items %}
+ {% assign lab = dcc.administrativeData.calibrationLaboratory %}
+ {% assign persons = dcc.administrativeData.respPersons %}
+ {% assign customer = dcc.administrativeData.customer %}
+ {% assign results = dcc.measurementResults %}
+ {% assign sv = dcc.schemaVersion %}
+
+
+
+
+
+
+
+
+
+
+
Unique ID
+
{{ core.uniqueIdentifier | default: "—" }}
+
+ {% if core.receiptDate %}
+
+
Receipt Date
+
{{ core.receiptDate }}
+
+ {% endif %}
+ {% if core.beginPerformanceDate %}
+
+
Performance Begin
+
{{ core.beginPerformanceDate }}
+
+ {% endif %}
+ {% if core.endPerformanceDate %}
+
+
Performance End
+
{{ core.endPerformanceDate }}
+
+ {% endif %}
+ {% if core.usedLangCodeISO639_1 %}
+
+
Languages
+
{{ core.usedLangCodeISO639_1 | join: ", " }}
+
+ {% endif %}
+ {% if core.mandatoryLangCodeISO639_1 %}
+
+
Mandatory Language
+
{{ core.mandatoryLangCodeISO639_1 }}
+
+ {% endif %}
+
+
+
+
+
+ {% assign item_list = items.item %}
+ {% if item_list %}
+
+
+
+ {% for item_hash in item_list %}
+ {% assign item = item_hash[1] | default: item_hash %}
+
+ {% if item.model %}
+
+
Model
+
{{ item.model }}
+
+ {% endif %}
+ {% if item.manufacturer %}
+
+
Manufacturer
+
+ {% if item.manufacturer.name.content._text %}
+ {{ item.manufacturer.name.content._text }}
+ {% elsif item.manufacturer.name.content.first %}
+ {{ item.manufacturer.name.content.first.last }}
+ {% else %}
+ {{ item.manufacturer.name.content }}
+ {% endif %}
+
+
+ {% endif %}
+
+ {% if item.identifications %}
+
+ | Identification Issuer | Value |
+
+ {% assign ids = item.identifications.identification %}
+ {% for id_hash in ids %}
+ {% assign id = id_hash[1] | default: id_hash %}
+ {% if id.issuer %}
+ | {{ id.issuer }} | {{ id.value }} |
+ {% endif %}
+ {% endfor %}
+
+
+ {% endif %}
+ {% endfor %}
+
+
+ {% endif %}
+
+
+ {% assign lab_contact = lab.contact %}
+ {% if lab_contact %}
+
+
+
+
+
+
Name
+
+ {% if lab_contact.name.content._text %}
+ {{ lab_contact.name.content._text }}
+ {% elsif lab_contact.name.content.first %}
+ {{ lab_contact.name.content.first.last }}
+ {% else %}
+ {{ lab_contact.name.content }}
+ {% endif %}
+
+
+ {% if lab_contact.eMail %}
+
+
Email
+
{{ lab_contact.eMail }}
+
+ {% endif %}
+ {% if lab_contact.phone %}
+
+
Phone
+
{{ lab_contact.phone }}
+
+ {% endif %}
+ {% if lab_contact.location %}
+
+
Address
+
+ {% if lab_contact.location.street %}{{ lab_contact.location.street }} {{ lab_contact.location.streetNo }}{% endif %}
+ {% if lab_contact.location.postCode %}
{{ lab_contact.location.postCode }} {{ lab_contact.location.city }}{% endif %}
+ {% if lab_contact.location.countryCode %}
{{ lab_contact.location.countryCode }}{% endif %}
+
+
+ {% endif %}
+
+
+
+ {% endif %}
+
+
+ {% assign person_list = persons.respPerson %}
+ {% if person_list %}
+
+
+
+ {% for person_hash in person_list %}
+ {% assign person = person_hash[1] | default: person_hash %}
+ {% if person.person %}
+
+
+ {% assign pname = "" %}
+ {% if person.person.name.content._text %}
+ {% assign pname = person.person.name.content._text %}
+ {% elsif person.person.name.content.first %}
+ {% assign pname = person.person.name.content.first.last %}
+ {% else %}
+ {% assign pname = person.person.name.content %}
+ {% endif %}
+ {{ pname | split: " " | last | truncate: 2, "" | upcase }}
+
+
+
{{ pname }}
+ {% if person.person.eMail %}
{{ person.person.eMail }}
{% endif %}
+
+ {% if person.mainSigner %}
Main Signer{% endif %}
+
+ {% endif %}
+ {% endfor %}
+
+
+ {% endif %}
+
+
+ {% assign mr_list = results.measurementResult %}
+ {% if mr_list %}
+
+
+
+ {% for mr_hash in mr_list %}
+ {% assign mr = mr_hash[1] | default: mr_hash %}
+
+
+ {% if mr.name.content._text %}
+ {{ mr.name.content._text }}
+ {% elsif mr.name.content.first %}
+ {{ mr.name.content.first.last }}
+ {% else %}
+ {{ mr.name.content }}
+ {% endif %}
+
+ {% if mr.usedMethods %}
+ {% assign methods = mr.usedMethods.usedMethod %}
+ {% for method_hash in methods %}
+ {% assign method = method_hash[1] | default: method_hash %}
+ {% if method.name %}
+
+ {% if method.name.content._text %}
+ {{ method.name.content._text }}
+ {% elsif method.name.content.first %}
+ {{ method.name.content.first.last }}
+ {% else %}
+ {{ method.name.content }}
+ {% endif %}
+
+ {% endif %}
+ {% endfor %}
+ {% endif %}
+ {% if mr.results %}
+ {% assign result_list = mr.results.result %}
+ {% if result_list %}
+
+ | Result |
+
+ {% for r_hash in result_list %}
+ {% assign r = r_hash[1] | default: r_hash %}
+ {% if r.name %}
+ |
+ {% if r.name.content._text %}
+ {{ r.name.content._text }}
+ {% elsif r.name.content.first %}
+ {{ r.name.content.first.last }}
+ {% else %}
+ {{ r.name.content }}
+ {% endif %}
+ |
+ {% endif %}
+ {% endfor %}
+
+
+ {% endif %}
+ {% endif %}
+
+ {% unless forloop.last %}
{% endunless %}
+ {% endfor %}
+
+
+ {% endif %}
+
+
+ {% if customer %}
+
+
+
+
+
+
Name
+
+ {% if customer.name.content._text %}
+ {{ customer.name.content._text }}
+ {% elsif customer.name.content.first %}
+ {{ customer.name.content.first.last }}
+ {% else %}
+ {{ customer.name.content }}
+ {% endif %}
+
+
+ {% if customer.eMail %}
+
+
Email
+
{{ customer.eMail }}
+
+ {% endif %}
+
+
+
+ {% endif %}
+
+
+
+