DEV Community

Discussion on: What do you guys use for formatting strings in javascript?

Collapse
 
alangdm profile image
Alan Dávalos

Why not just use string template literals? developer.mozilla.org/en-US/docs/W...

Collapse
 
nombrekeff profile image
Keff

Yes, It could be accomplished using template literals, although for the use case I needed it for, it was not enough, I needed to process each string segment separately and process it in some way, also needed something where I could easily enable and disable some part of the formatting (which we call transformers within strif)

For example:

  • To color specific segments of the log.
  • Enabling/disabling color.
  • Having multiple transformers per segment.
  • But most importantly to not add complexity for the user that is not needed.

But yes, for most cases I think template literals are good enough.