lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 1229745 020/156: Make add_body_paragraph() ev


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 1229745 020/156: Make add_body_paragraph() even more convenient to use
Date: Tue, 30 Jan 2018 17:21:53 -0500 (EST)

branch: master
commit 1229745e4da17b4fc7eefbd237b84547f4e1c1d1
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>

    Make add_body_paragraph() even more convenient to use
    
    Fold interpolate_html() call inside it while keeping a separate
    add_body_paragraph_html() which can be used if we need to construct HTML
    manually.
---
 ledger_pdf_generator_wx.cpp | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index d27dfea..cc77bde 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -89,6 +89,11 @@ class html_interpolator
             );
     }
 
+    text operator()(std::string const& s) const
+    {
+        return (*this)(s.c_str());
+    }
+
     // Add a variable, providing either its raw text or already escaped HTML
     // representation. Boolean values are converted to strings "0" or "1" as
     // expected.
@@ -459,11 +464,16 @@ class narrative_summary_page : public page
             ;
 
         // Just a helper performing a common operation.
-        auto const add_body_paragraph = [](text const& t) -> text
+        auto const add_body_paragraph_html = [](text const& t) -> text
             {
             return tag::p(tag::font[attr::size("-1")](t));
             };
 
+        auto const add_body_paragraph = [=](std::string const& s) -> text
+            {
+            return add_body_paragraph_html(interpolate_html(s));
+            };
+
         std::string description;
         if(!interpolate_html.test_variable("SinglePremium"))
             {
@@ -500,14 +510,12 @@ adjustable benefits, and single premium.
 )";
             }
 
-        summary_html += add_body_paragraph
-            (interpolate_html(description.c_str())
-            );
+        summary_html += add_body_paragraph(description);
 
         if(!invar.IsInforce)
             {
             summary_html += add_body_paragraph
-                (interpolate_html(R"(
+                (R"(
 Coverage may be available on a Guaranteed Standard Issue basis.
 All proposals are based on case characteristics and must
 be approved by the ${InsCoShortName}
@@ -515,7 +523,7 @@ Home Office. For details regarding underwriting
 and coverage limitations refer to your offer letter
 or contact your ${InsCoShortName} representative.
 )"
-                ));
+                );
             }
 
         writer.output_html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]