[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 41de2e2 140/156: Add helper expand_template()
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 41de2e2 140/156: Add helper expand_template() method |
Date: |
Tue, 30 Jan 2018 17:22:33 -0500 (EST) |
branch: master
commit 41de2e21ed4b851d459bae5c69bc89904aef0962
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Add helper expand_template() method
No real changes, just simplify the code a little by providing a method
for interpolating the contents of an external template removing the need
to manually create "{{>template_name}}" strings and interpolating them.
---
ledger_pdf_generator_wx.cpp | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index ef1bd4b..c9e017e 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -232,6 +232,15 @@ class html_interpolator
return evaluator_(name, index);
}
+ // Interpolate the contents of the given external template.
+ //
+ // This is exactly the same as interpolating "{{>template_name}}" string
+ // but a bit more convenient to use and simpler to read.
+ text expand_template(std::string const& template_name) const
+ {
+ return (*this)("{{>" + template_name + "}}");
+ }
+
private:
// The expansion function used with interpolate_string().
text expand_html(std::string const& s) const
@@ -687,7 +696,7 @@ class page
(writer.get_horz_margin()
,writer.get_vert_margin()
,writer.get_page_width()
- ,interpolate_html("{{>" + template_name + "}}")
+ ,interpolate_html.expand_template(template_name)
);
}
@@ -846,7 +855,7 @@ class pdf_illustration : protected html_interpolator
add_variable
("HasComplianceTrackingNumber"
- ,(*this)("{{>compliance_tracking_number}}")
+ ,expand_template("compliance_tracking_number")
.as_html().find_first_not_of(" \n")
!= std::string::npos
);
@@ -989,7 +998,7 @@ class page_with_footer : public page
(frame_horz_margin
,0
,frame_width
- ,interpolate_html("{{>" + upper_template + "}}")
+ ,interpolate_html.expand_template(upper_template)
,e_output_measure_only
);
@@ -1024,7 +1033,7 @@ class page_with_footer : public page
(frame_horz_margin
,y
,frame_width
- ,interpolate_html("{{>" + upper_template + "}}")
+ ,interpolate_html.expand_template(upper_template)
);
}
@@ -1649,7 +1658,9 @@ class page_with_tabular_report
(writer.get_horz_margin()
,pos_y
,writer.get_page_width()
- ,interpolate_html("{{>" + get_fixed_page_contents_template_name()
+ "}}")
+ ,interpolate_html.expand_template
+ (get_fixed_page_contents_template_name()
+ )
,output_mode
);
- [lmi-commits] [lmi] master d7244c1 043/156: Change the colour used for lines and borders, (continued)
- [lmi-commits] [lmi] master d7244c1 043/156: Change the colour used for lines and borders, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 41ae40d 089/156: Fix wrong "<br>" tag in the header template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master acb7aae 049/156: Add numbered_page::get_extra_pages_needed() hook, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master c0d68e1 122/156: Add rate of return pages of the individual placement illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 875ca7d 039/156: Rename StateIsTX ledger variable to StateIsTexas, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 31048c8 047/156: Make wx_table_generator even more customizable, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 10dd0a9 051/156: Factor enum_output_mode into a separate header to allow its reuse, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 8fa972e 052/156: Add "Tabular Detail, continued" page to the PDF illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ca6e17c 031/156: Add function generating a standard header and use it, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master c378bc5 064/156: Remove unnecessary value_cast inclusion, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 41de2e2 140/156: Add helper expand_template() method,
Greg Chicares <=
- [lmi-commits] [lmi] master 3e8e257 017/156: Add pdf_illustration_regular and narrative_summary_page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 614fb47 135/156: Add supplemental reports pages to private placement illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 49cc809 072/156: Remove HTML construction helpers not needed any more, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master efc01fa 046/156: Allow disabling separator lines in wx_table_generator, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e20544f 018/156: Add check for the ledger type, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master a0a167e 144/156: Rename "compliance_tracking_number" template to "imprimatur", Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 982c9f0 149/156: Remove consecutive blank lines from a Mustache template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ec73905 058/156: Add extra pair of braces to std::array<> initializer for clang, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 6a5cd32 079/156: Add "Table Rating" to the header if necessary, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b01d478 029/156: Resurrect ledger XML IO code as new ledger_evaluator, Greg Chicares, 2018/01/30