[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Variables synthesized in 'pdf_command_wx.cpp'
From: |
Greg Chicares |
Subject: |
Re: [lmi] Variables synthesized in 'pdf_command_wx.cpp' |
Date: |
Tue, 5 Feb 2019 16:32:29 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
[BTW, let me explicitly confirm your assumption that in the great majority
of cases I'd mentioned, I'm not asking you to do anything. But lambdas
could be interesting...]
On 2019-02-03 00:48, Vadim Zeitlin wrote:
> On Sat, 2 Feb 2019 23:52:56 +0000 Greg Chicares <address@hidden> wrote:
[...]
> GC> shortened strings:
> GC> add_abbreviated_variable("CorpName", 60);
> GC> add_abbreviated_variable("CorpName", 50);
> GC> add_abbreviated_variable("CorpName", 140);
[...]
> GC> Similarly, could a 'width=' attribute be used here?
[...no, because characters have different widths, but...]
> OTOH I did think about adding some generic mechanism for getting first N
> characters of any existing variable, e.g. writing the interpolation
> function in such a way that requesting "Foo_first_N" would return the
> substring of (at most) N leading characters of the result of interpolating
> "Foo". But it looked like a hack (probably because it is)
Agreed. We already have suffixes like "_Guar", and compounding that
complication would be like repeating a bad joke.
> [...] Or we could just implement support for
> Mustache lambdas or Handlebars block helpers which both basically allow
> applying arbitrary functions to the variable values and then we could use
> something like {{First(CorpName, 60)}} instead. But this would require
> slightly more effort, of course.
That's a really attractive idea. It doesn't have to be done at this moment,
and it'll probably entail a lot of effort. But let me make a "wish list":
* "{{First(CorpName, 60)}}" as above. Maybe the name should be {{Abbrev}}
because we'll never want {{Last}}, and we might want to mark abbreviated
strings something like this:
- This is the full, very lengthy, verbose string.
+ This is the full...
* {{IfNonempty}}, so that where we have something like this:
{{#HasWP}}
<p>The Waiver of Monthly Charges Rider provides for waiver
of monthly charges in the event of [...] </p>
{{/HasWP}}
we could move the text into a '.product' file, then print it iff it's
not null. (AIUI, perhaps incorrectly, MST expands an empty string to
some kind of whitespace.)
* Some kind of if...elif...else; IIRC, handlebars has that already.
* Simple arithmetic, e.g. {{Add(MecYear), 1}} instead of defining an
auxiliary variable {{MecYearPlus1}}. Even an {Origin1} function that
returns one plus its argument would be useful.