Last active
August 6, 2020 13:39
-
-
Save brasilikum/3cd515bad5541ca6c76873faf10445c2 to your computer and use it in GitHub Desktop.
turn mjml into html and txt.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check if mjml is installed | |
if ! [ -x "$(command -v mjml)" ]; then | |
echo 'Error: mjml is not installed. Install with "npm install -g mjml"' >&2 | |
exit 1 | |
fi | |
# Check if html-to-text is installed | |
if ! [ -x "$(command -v html-to-text)" ]; then | |
echo 'Error: html-to-text is not installed. Install with "npm install -g html-to-text"' >&2 | |
exit 1 | |
fi | |
# Run command for all files passed as arguments to the script | |
for FILENAME in "$@" | |
do | |
echo Input: $FILENAME | |
FILENAME=${FILENAME%.*} | |
mjml -o $FILENAME.html $FILENAME.mjml | |
cat $FILENAME.html | html-to-text > $FILENAME.txt | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compile one file
mjml-2-mjml-and-txt.sh mail.mjml
Compile all mjml files in the current directory
mjml-2-mjml-and-txt.sh *.mjml