Highlights for Literal Variables surrounded by " ` ".

Discuss any editing or program related subjects.
Post Reply
msall
Posts: 7
Joined: 03 Feb 2022 19:59

Highlights for Literal Variables surrounded by " ` ".

Post by msall »

Highlights for Literal Variables surrounded by " ` "

Example: `Content`

How to do this?

In Customize Theme Environment, there is no Possibility of Inclusion.

In the Syntax editor, I didn't understand how to do this.

I would like this highlight to be available for all Languages, or at least HTML, Javascript, PHP, Java.

Thanks
User avatar
pjj
Posts: 2109
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: Highlights for Literal Variables surrounded by " ` ".

Post by pjj »

If you want to use backtick char (`) to denote "characters" (I use terminology from the Theme Manager: characters, string, text), then I'm afraid I have bad news for you: it is impossible to use backtick and single quote at the same time for the same purpose -- at least for PHP, for which I made a quick test. Anyway, it can be set in the Syntax Editor (Options > Syntax > Char), but only the first char put there is used.

Why would you want to do it, anyway? Backticks in PHP do not delimit strings.
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
msall
Posts: 7
Joined: 03 Feb 2022 19:59

Re: Highlights for Literal Variables surrounded by " ` ".

Post by msall »

Note that "Literal Strings" or "Template strings" has dozens of applications in javascript, html, less, php, among others.

I've already developed more elegant, maintainable, and much leaner code using this feature.

ECMA-262 and ISO/IEC 16262 since 2015 already have this as standard.

65% of what PHP, in real life, does is write server-side "pages" that will be interpreted and displayed by the client-side browser, many of them with quite complex functionality.

Don't be fooled by my simple questions...

I have much more expertise and multidisciplinary knowledge than you can imagine...

And on occasion, it is good to point out that as developers of this type of application, it is more beneficial for you to identify users' needs than to question the reason for these needs, since the vast majority are professionals in the area.

Thanks.
User avatar
pjj
Posts: 2109
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: Highlights for Literal Variables surrounded by " ` ".

Post by pjj »

msall wrote: 03 Apr 2022 17:31 And on occasion, it is good to point out that as developers of this type of application, it is more beneficial for you to identify users' needs than to question the reason for these needs, since the vast majority are professionals in the area.
This is debatable, but that's not the point: the point is I'm not a developer of RJ TE and I didn't want to question (as in put in doubt) the reason for your needs, I was simply curious and hoped I would learn something new about use of backticks in PHP.
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus
User avatar
Rickard Johansson
Site Admin
Posts: 6577
Joined: 19 Jul 2006 14:29

Re: Highlights for Literal Variables surrounded by " ` ".

Post by Rickard Johansson »

I experimented a bit and this is what I came up with.

In the JScript.syx file add the following in the [Block] section:

Code: Select all

[Block]
...
3_Name=Template literals
3_OnLine=0
3_AsString=0
3_Start=`
3_End=`
3_FirstOnLine=0
3_OnlyAfter=
3_HighlightKeywords=1
3_HighlightNumbers=1
3_HighlightSymbols=1
3_HighlightBlocks=1
3_HighlightStrings=0
3_HighlightChars=0
4_Name=Expressions
4_OnLine=0
4_AsString=0
4_Start=${
4_End=}
4_FirstOnLine=0
4_OnlyAfter=
4_HighlightKeywords=1
4_HighlightNumbers=1
4_HighlightSymbols=1
4_HighlightBlocks=1
4_HighlightStrings=0
4_HighlightChars=0
2022-04-04_151633.png
2022-04-04_151633.png (5.97 KiB) Viewed 7160 times

Is it enough or is anything missing?
User avatar
Rickard Johansson
Site Admin
Posts: 6577
Joined: 19 Jul 2006 14:29

Re: Highlights for Literal Variables surrounded by " ` ".

Post by Rickard Johansson »

Except for in JavaScript I'm not sure this is widely used.

Backticks in PHP are used to create an Execution Operator.

2022-04-04_175819.png
2022-04-04_175819.png (2.13 KiB) Viewed 7152 times

I've added support for those as well.

But how are backticks used in LESS or HTML ?
msall
Posts: 7
Joined: 03 Feb 2022 19:59

Re: Highlights for Literal Variables surrounded by " ` ".

Post by msall »

Simple examples:

They are responsible for the reliable transmission of attribute states and properties. Many of these properties can take on complex values, including for integrity checking.

In JS they are extremely useful for creating templates.

Javascript is an interpreted language (in loco) that structures like:

"Something here" + variable + "Continuing something"...

They can degrade application performance quickly.

Many do not use, because they only do the basics, but if you look at the code of good frameworks (> 2015), they are full of this kind of structure!


In PHP, this example is Basic of Basic, and could be replaced without too much trouble, but there are much nobler uses in this language for " ` "!

Thanks for your support!
Attachments
Ex.jpg
Ex.jpg (61.76 KiB) Viewed 7004 times
Post Reply