Drillster / drone-email

Drone plugin for sending email notifications
Apache License 2.0
44 stars 43 forks source link

How to convert line break (\n\r) to <br> #67

Open mashirozx opened 2 years ago

mashirozx commented 2 years ago

Hello, do you have any idea on how to convert \n or \r in strings? For example, I'm using variable ${DRONE_COMMIT_MESSAGE} which may output like this:

IMG_20220619_114207

mjwwit commented 2 years ago

Although I haven't had to do this myself, this is probably what I'd try first: I'd prepend a step where you use ${DRONE_COMMIT_MESSAGE} to create a custom email template file, replacing any \r\n instances with <br />. If you store this file in the project working directory, drone will keep it for the drone-email step. There you can simply refer to the custom template file you just created.

mashirozx commented 2 years ago

Thanks for your suggestion @mjwwit. But my workflow was build a public Docker image, which I think can't place a template in work directory.

I'm considering adding an auto convert line break option to drone-email, will such kind of PR be welcomed?

glaszig commented 1 year ago

i tried to add proper functionality for this to the template lib, see drone/drone-template-lib#12, but drone is a money operation now.

so i forked it and built my own drone-email. with that version you can do this:

{{ htmlLineBreaks commit.message }}

my fork is the same as drillster's only it's built with the updated template lib.