Skip to content

Instantly share code, notes, and snippets.

@brasilikum
Last active August 6, 2020 13:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brasilikum/3cd515bad5541ca6c76873faf10445c2 to your computer and use it in GitHub Desktop.
Save brasilikum/3cd515bad5541ca6c76873faf10445c2 to your computer and use it in GitHub Desktop.
turn mjml into html and txt.
# 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
@brasilikum
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment