Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I wouldn't, personally. Backticks to me signify that I'm expecting to see embedded vars and/or multiline strings. If I see backticks and there's neither of those, that rings a little bell in my head that says something doesn't seem right and needs investigating further. I think you'll find most standard JS linting rulesets will say similar, and flag any such "misused" template literals.
Plus, they're not going to be sensible in *every* situation. If you had a pre-formatted string, using no variables, that contained backticks, that'd be kinda insane. -
kiki349474y@AlmondSauce I thought the same way but once I tried it I felt so relieved that I don't need escaping neither double nor single quotes
-
@AlmondSauce Yeah, ESLint will warn you (or possibly chuck errors) about that when there are no embedded variables or if there are no (double) quotes inside.
-
kiki349474y@SortOfTested so you pick single quotes when your text contains double quotes and you pick double quotes when your text contains an apostrophe. If it contains both you either concatenate strings or escape characters, because there is no other way since you don’t use backticks when there is no templates involved
-
@uyouthe
I don't tend to have large constant blocks of text in my code, so that's not really an issue for me. To my mind that sort of data is/should be configuration. -
kiki349474y@SortOfTested my everyday workflow includes rapid prototyping with i18n which accepts strings
-
@uyouthe
Sounds like it's unqjue to your use case.
Our i18n powers from id and loads dictionary files. The transformations load from a factory which serves xliff notation rules, so the only thing that manifests in the front end code/templates is a keyed binding target identifier (ex: viewId:displayFieldId). The strings, pluralization, conditional sets, etc are all in external config.
Translations load from a rest call with the local language. The code itself has none of the content.
I don’t know about you but I use backticks for every string in js. I want to know that I can always use quotes and apostrophes and backticks ensure this. Also they allow templates and Babel got me covered when it comes to old browsers.
I don’t see the reason why should I use something but backticks in 2020
Again,
` — kiki
“, ‘ — boubas
random