Commit 30650a96 authored by Michael Witrant's avatar Michael Witrant
Browse files

render all amendments in template

parent 7410766c
...@@ -97,11 +97,10 @@ class AmendmentExtractor ...@@ -97,11 +97,10 @@ class AmendmentExtractor
doc_amend = amend_doc.xpath("//DocAmend").first.text doc_amend = amend_doc.xpath("//DocAmend").first.text
article = amend_doc.xpath("//Article").first.text article = amend_doc.xpath("//Article").first.text
amendment = { amendment = OpenStruct.new
num: num_am, amendment.num = num_am
doc: doc_amend, amendment.doc = doc_amend
article: article, amendment.article = article
}
debug amendment debug amendment
...@@ -145,7 +144,7 @@ class AmendmentExtractor ...@@ -145,7 +144,7 @@ class AmendmentExtractor
raise "amendment changes not found" if changes.size == 0 raise "amendment changes not found" if changes.size == 0
debug changes: changes debug changes: changes
amendment[:changes] = changes amendment.changes = changes
amendments << amendment amendments << amendment
...@@ -155,13 +154,8 @@ class AmendmentExtractor ...@@ -155,13 +154,8 @@ class AmendmentExtractor
debug "rendering amendments" debug "rendering amendments"
template = ERB.new File.read('template.erb'), nil, '-' template = ERB.new File.read('template.erb'), nil, '-'
result = [] erb_binding = OpenStruct.new(amendments: amendments).instance_eval { binding }
amendments.each do |amendment| output = template.result(erb_binding)
amendment_binding = OpenStruct.new(amendment).instance_eval { binding }
output = template.result(amendment_binding)
result << output
end
result.join("\n")
end end
end end
......
=== Amendment <%= num %> === <% amendments.each do |amendment| -%>
=== Amendment <%= amendment.num %> ===
{| border="1" style="border-spacing:0;" cellpadding="3" width="100%" {| border="1" style="border-spacing:0;" cellpadding="3" width="100%"
|- |-
! colspan="2" style="background-color: lightgrey;" | ! colspan="2" style="background-color: lightgrey;" |
Amendement <%= num %> Amendement <%= amendment.num %>
<br/> <br/>
<%= article %> <%= amendment.article %>
<% changes.each do |original, changed| -%> <% amendment.changes.each do |original, changed| -%>
|- |-
|width="50%"| |width="50%"|
<%= original %> <%= original %>
...@@ -17,3 +18,4 @@ Amendement <%= num %> ...@@ -17,3 +18,4 @@ Amendement <%= num %>
Comments: Comments:
|} |}
<% end -%>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment