Pass function result to shortcode

I found GitHub - martignoni/hugo-cloak-email: A Hugo theme component to cloak email adresses, and I would like to use it with an email read from a secret file, to avoid the email being read from a bot parsing the github repository with the markdown files.

I thought about something like {{< cloakemail {{ os.ReadFile "email.txt" }} >}} in my content, but I can’t find a way to pass the result of os.ReadFIle to the shortcode

Is this possible ?

You can only pass strings, booleans, and integers as parameters in a shortcode code. You could pass the file name and do the os.ReadFile bit within the shortcode.

Thanks for your answer !

You can only pass strings, booleans, and integers as parameters in a shortcode code

but doesn’t os.ReadFile return a string ?

You could pass the file name and do the os.ReadFile bit within the shortcode.

Is there a way to encapsulate their shortcude rather than modifying it ? (For example by calling their shortcode inside my own ?)
I don’t really mind modifying their directly, but I would like not to if possible

You are trying to pass template code, not a string.

Override the theme’s shortcode by placing a copy in the layouts/shortcodes directory in the root of your project. That’s how you override any theme file.

Okay, I will do that then. Thanks

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.