lmi
[Top][All Lists]
Advanced

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

Re: [lmi] Superfluous spaces around {{>partial}}


From: Vadim Zeitlin
Subject: Re: [lmi] Superfluous spaces around {{>partial}}
Date: Fri, 31 Aug 2018 20:42:19 +0200

On Fri, 31 Aug 2018 12:11:31 +0000 Greg Chicares <address@hidden> wrote:

GC> With the following experimental patch to emphasize spacing:
GC> 
GC> 
---------8<--------8<--------8<--------8<--------8<--------8<--------8<-------
GC> diff --git a/ill_reg_footer.mst b/ill_reg_footer.mst
GC> index f4d0dceb..39de8e2d 100644
GC> --- a/ill_reg_footer.mst
GC> +++ b/ill_reg_footer.mst
GC> @@ -28,12 +28,12 @@
GC>      <tr>
GC>          <td>Date Prepared: {{date_prepared}}</td>
GC>          <td align="center">{{page_number}}</td>
GC> -        <td align="right">{{InsCoName}}</td>
GC> +        <td align="right">|{{InsCoName}}|</td>
GC>      </tr>
GC>      <tr>
GC>          <td>System Version: {{LmiVersion}}</td>
GC>          <td>&nbsp;</td>
GC> -        <td align="right">{{>imprimatur}}</td>
GC> +        <td align="right">|{{>imprimatur}}|</td>
GC>      </tr>
GC>  </table>
GC>  
GC> 
--------->8-------->8-------->8-------->8-------->8-------->8-------->8-------
GC> 
GC> ...on a 'sample2naic' illustration, the right-hand side of the footer
GC> looks like this:
GC> 
GC> | {ImprimaturPresale} |
GC> |{InsCoName}|
GC> 
GC> with superfluous spaces surrounding the {{>partial}}. Can that unwanted
GC> space be suppressed?

 Currently, not really. Official Mustache preserves whitespace and so my
own implementation of it does it too and this means that while all the
other blocks, except the one expanding into "{ImprimaturPresale}",
from imprimatur.mst disappear, the whitespace between them is still left.
I.e. the actual expansion of imprimatur.mst is similar to something like
"\n\n\n\n \n {ImprimaturPresale}\n    \n\n".

 So to avoid whitespace currently we'd have to put all the contents of
imprimatur.mst on a single line which wouldn't be very convenient.

GC> Even if this particular example may not matter much,

 The idea was that the whitespace in HTML shouldn't matter at all.

GC> I anticipate that
GC> the extra space might look worse in other cases not yet discovered.

 Maybe it would be better to wait until we discover them?

GC> I could fix it in this particular case by defining a variable like
GC> {{TheContextualImprimatur}} and assigning it in C++ rather than in an
GC> MST template, but I'm wondering whether there's a general solution.

 While one doesn't exist currently, it could be implemented. I don't think
that suppressing all the extra whitespace would be a good idea neither, but
we could implement some smarter algorithm, e.g. avoid new lines after
blocks that expand to nothing and leading/trailing spaces after a block.

GC> I thought the extra spaces might come from whitespace in 'imprimatur.mst',
GC> but reducing the body of that template to a single 270-character line
GC> with no whitespace doesn't affect the output.

 Are you absolutely certain about this? Because it definitely does do it
for me. Here is my 270-character line, just in case:

{{#IsInforce}}{{#Composite}}{{ImprimaturInforceComposite}}{{/Composite}}{{^Composite}}{{ImprimaturInforce}}{{/Composite}}{{/IsInforce}}{{^IsInforce}}{{#Composite}}{{ImprimaturPresaleComposite}}{{/Composite}}{{^Composite}}{{ImprimaturPresale}}{{/Composite}}{{/IsInforce}}

Note that you will need to set Vim "fixeol" to false and possibly reset
"eol" to false too to make Vim write this file without the trailing new
line that it helpfully adds by default.

 Regards,
VZ


reply via email to

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