Silly and likely non-important question about StringTemplates.
forax at univ-mlv.fr
forax at univ-mlv.fr
Mon Oct 23 13:05:51 UTC 2023
> From: "David Alayachew" <davidalayachew at gmail.com>
> To: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "amber-dev" <amber-dev at openjdk.org>
> Sent: Monday, October 23, 2023 3:01:32 PM
> Subject: Re: Silly and likely non-important question about StringTemplates.
> Hello Rémi,
> Thank you for your response!
> I am making a SWING_HTML String Template Processor that turns basic multi-line
> strings into ones that are <html> enclosed, and replace new lines with <br>.
> So, for me, most of my Strings are already made, and thus, don't need to have
> anything "inserted" into them.
> private static final Processor<String, RuntimeException> SWING_HTML =
> st ->
> "<html>"
> +
> st
> .interpolate()
> .lines()
> .collect(java.util.stream.Collectors.joining("<br>"))
> +
> "</html>"
> ;
> It would be nice if Java put this particular processor into the Swing library
> itself at some point. But it's easy enough for me to implement myself, which is
> a nice thing about String Templates. Plus, this feature composes -- I can make
> an italics or bold processor that can translate to the various html tags that
> Swing supports. And it's safer than just putting in the tags myself because the
> curly braces will turn into compiler errors if I don't align them correctly.
> Plus, curly braces are a syntax feature, so most ide's (even VIM and EMACS!)
> will give you hints about where your curly braces are, making it much easier to
> trace issues with this.
Hello,
don't forget to escape <, > et & correctly.
> Thank you for your time and help!
> David Alayachew
regards,
Rémi
> On Mon, Oct 23, 2023 at 1:06 AM Remi Forax < [ mailto:forax at univ-mlv.fr |
> forax at univ-mlv.fr ] > wrote:
>>> From: "David Alayachew" < [ mailto:davidalayachew at gmail.com |
>>> davidalayachew at gmail.com ] >
>>> To: "amber-dev" < [ mailto:amber-dev at openjdk.org | amber-dev at openjdk.org ] >
>>> Sent: Monday, October 23, 2023 6:35:00 AM
>>> Subject: Silly and likely non-important question about StringTemplates.
>>> Hello Amber Dev Team,
>>> I've been playing with StringTemplates a bit more, and I had a quick question.
>>> I repeatedly find myself in the same situation -- I have a String that is
>>> already in a variable, and I want it to be the full String in the
>>> StringTemplate. What is the recommended way to do it?
>>> For example.
>>> String abc = "xyz";
>>> MY_PROCESSOR. <--- what goes here?
>> MY_PROCESSOR."\{abc}"
>>> Thank you for your time!
>>> David Alayachew
>> regards,
>> Rémi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20231023/8b3277f8/attachment-0001.htm>
More information about the amber-dev
mailing list