shlogg · Early preview
Ramu Narasinga @karthik-m22

String.raw In Tailwindcss Source Code Analysis

String.raw used in Tailwindcss source code for raw string form of template literals, preserving escape sequences.

In this article, we analyze the usage of String.raw in Tailwindcss source code.

  
  
  String.raw

MDN documentation says that:
“The String.raw() static method is a tag function of template literals.
This is similar to the r prefix in Python, or the @ prefix in C# for string literals.
It’s used to get the raw string form of template literals — that is, substitutions
(e.g. ${foo}) are processed, but escape sequences (e.g. \n) are not.“
  
  
  Example 1:

The below example is picked from MDN:

// Create a variable that uses a Windows
// path without escaping the backslashes:
const filePath =...