0

Sometimes as a backend developer I have to send html to client's inbox for password recovery or some other reasons. I code mail body in html inside js file and wrap it with backticks because i might need to pass some variable. But i always have to manually format html code line by line. Prettier can't seem to be able to format it for me.

Is there any way to format the html wrapped with backticks in js file?

1 Answers1

0

You can put the html in a separate file. Let prettier format it as html source. On demand you can read the content from the file, interpolate the variables and pass to client.

You can also use some templating library for variable interpolation. If you don't want that, for interpolating variables you can do as per this post.

ashutosh
  • 324
  • 2
  • 8