[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 34c088c 073/156: Move footer contents into an
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 34c088c 073/156: Move footer contents into an external template too |
Date: |
Tue, 30 Jan 2018 17:22:14 -0500 (EST) |
branch: master
commit 34c088c29d6951b4df33ea1bf4132f720cd741fd
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Move footer contents into an external template too
This will allow customizing footer more easily.
---
footer.mustache | 36 +++++++++++++
ledger_pdf_generator_wx.cpp | 123 +++++++++++++++++---------------------------
2 files changed, 82 insertions(+), 77 deletions(-)
diff --git a/footer.mustache b/footer.mustache
new file mode 100644
index 0000000..d675000
--- /dev/null
+++ b/footer.mustache
@@ -0,0 +1,36 @@
+<font size="-2">
+
+<table width="100%" cellspacing="0" cellpadding="0">
+ <tr>
+ <td colspan="3"> </td>
+ </tr>
+ <tr>
+ <td>Date Prepared: {{date_prepared}}</td>
+ <td align="center">{{footer_contents}}</td>
+ <td align="right">{{InsCoName}}</td>
+ </tr>
+ <tr>
+ <td>System Version: {{LmiVersion}}</td>
+ <td> </td>
+ <td align="right">
+ {{#IsInforce}}
+ {{#Composite}}
+ {{ImprimaturInforceComposite}}
+ {{/Composite}}
+ {{^Composite}}
+ {{ImprimaturInforce}}
+ {{/Composite}}
+ {{/IsInforce}}
+ {{^IsInforce}}
+ {{#Composite}}
+ {{ImprimaturPresaleComposite}}
+ {{/Composite}}
+ {{^Composite}}
+ {{ImprimaturPresale}}
+ {{/Composite}}
+ {{/IsInforce}}
+ </td>
+ </tr>
+</table>
+
+</font>
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 1a8974f..65db474 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -85,6 +85,27 @@ class html_interpolator
{
}
+ // This function is provided to be able to delegate to it in custom
+ // interpolation functions, but usually shouldn't be called directly, just
+ // use operator() below instead.
+ std::string interpolation_func
+ (std::string const& s
+ ,interpolate_lookup_kind kind
+ ) const
+ {
+ switch(kind)
+ {
+ case interpolate_lookup_kind::variable:
+ case interpolate_lookup_kind::section:
+ return expand_html(s).as_html();
+
+ case interpolate_lookup_kind::partial:
+ return load_partial_from_file(s);
+ }
+
+ throw std::runtime_error("invalid lookup kind");
+ }
+
// A method which can be used to interpolate an HTML string containing
// references to the variables defined for this illustration. The general
// syntax is the same as in the global interpolate_string() function, i.e.
@@ -105,19 +126,9 @@ class html_interpolator
,[this]
(std::string const& s
,interpolate_lookup_kind kind
- ) -> std::string
+ )
{
- switch(kind)
- {
- case interpolate_lookup_kind::variable:
- case interpolate_lookup_kind::section:
- return expand_html(s).as_html();
-
- case interpolate_lookup_kind::partial:
- return load_partial_from_file(s);
- }
-
- throw std::runtime_error("invalid lookup kind");
+ return interpolation_func(s, kind);
}
)
);
@@ -609,72 +620,30 @@ class page_with_footer : public page
// This method uses get_footer_contents() and returns the HTML wrapping it
// and other fixed information appearing in the footer.
- html::text get_footer_html(html_interpolator const& interpolate_html) const
+ text get_footer_html(html_interpolator const& interpolate_html) const
{
- return
- tag::font[attr::size("-2")]
- (tag::table[attr::width("100%")]
- [attr::cellspacing("0")]
- [attr::cellpadding("0")]
- (tag::tr
- (tag::td[attr::colspan("3")]
- (text::nbsp())
- )
- )
- (tag::tr
- (tag::td
- (interpolate_html
- ("Date Prepared: {{date_prepared}}"
- )
- )
- )
- (tag::td[attr::align("center")]
- (text::from(get_footer_contents())
- )
- )
- (tag::td[attr::align("right")]
- (interpolate_html
- ("{{InsCoName}}"
- )
- )
- )
- )
- (tag::tr
- (tag::td
- (interpolate_html
- ("System Version: {{LmiVersion}}"
- )
- )
- )
- (tag::td
- (text::nbsp()
- )
- )
- (tag::td[attr::align("right")]
- (interpolate_html
- (R"(
- {{#IsInforce}}
- {{#Composite}}
- {{ImprimaturInforceComposite}}
- {{/Composite}}
- {{^Composite}}
- {{ImprimaturInforce}}
- {{/Composite}}
- {{/IsInforce}}
- {{^IsInforce}}
- {{#Composite}}
- {{ImprimaturPresaleComposite}}
- {{/Composite}}
- {{^Composite}}
- {{ImprimaturPresale}}
- {{/Composite}}
- {{/IsInforce}}
- )"
- )
- )
- )
- )
- );
+ auto const contents = get_footer_contents();
+
+ // Use our own interpolation function to handle the special
+ // "footer_contents" variable that is replaced with the actual
+ // (possibly dynamic) footer contents.
+ return text::from_html
+ (interpolate_string
+ ("{{>footer}}"
+ ,[contents, interpolate_html]
+ (std::string const& s
+ ,interpolate_lookup_kind kind
+ ) -> std::string
+ {
+ if(s == "footer_contents")
+ {
+ return contents;
+ }
+
+ return interpolate_html.interpolation_func(s, kind);
+ }
+ )
+ );
}
int footer_top_ = 0;
- [lmi-commits] [lmi] master 7c0ff88 145/156: Add copyright notices to all .mst template files, (continued)
- [lmi-commits] [lmi] master 7c0ff88 145/156: Add copyright notices to all .mst template files, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 2fd6a11 147/156: Use shorter and more consistent names for external templates, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master b09a25f 026/156: Implement numbering pages in the PDF output, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master bb75971 033/156: Implement the second part of the narrative summary page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 964db82 067/156: Rename columns_headings_page to column_headings_page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 2a94469 074/156: Use Mustache template files from the data directory, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 01be23a 103/156: Automatically squeeze table columns to make them fit if necessary, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 46a7442 068/156: Factor out helper render_template() method, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d77620f 100/156: Factor out dollar_units template from the existing ones, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 833eef5 086/156: Use std::make_unique<> instead of raw "new", Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 34c088c 073/156: Move footer contents into an external template too,
Greg Chicares <=
- [lmi-commits] [lmi] master 0ba1c32 146/156: Consistently use "curr" as abbreviation of "current", Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 29865fc 133/156: Add supplemental report to NASD illustrations too, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 919d796 001/156: Remove old XSL-FO-based PDF generation code, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master cc7fc05 143/156: Change template file extension from .mustache to .mst, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 08984bb 148/156: Recognize Mustache files in the coding rules test, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master de5a5c7 151/156: Fix interpolate_string_test build, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master bb5693e 136/156: Harmonize spacing in header in reg_d_group illustrations too, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 0c85a7a 154/156: Avoid using directive for the "html" namespace, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 463e8ca 138/156: Fix bug with page numbers in subsequent illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 830e1fd 130/156: Manually break column titles into lines, Greg Chicares, 2018/01/30