Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mashirozx opened this issue Jun 19, 2022 · 3 comments
Open

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

mashirozx opened this issue Jun 19, 2022 · 3 comments

Comments

@mashirozx
Copy link

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
Copy link
Collaborator

mjwwit commented Jun 19, 2022

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
Copy link
Author

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
Copy link
Contributor

glaszig commented Feb 8, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants