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

Beautify option #12

Merged
merged 2 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ENV CORS=""
ENV MJML_KEEP_COMMENTS=false
ENV MJML_VALIDATION_LEVEL=soft
ENV MJML_MINIFY=true
ENV MJML_MINIFY=false

COPY package* ./

Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Due to various challenges this image sports the following features:
- Supports healthchecks.

# Table of contents
- [Overview](#overview)
- [Defaults](#defaults)
- [Development](#development)
- [Troubleshooting](#troubleshooting)
- [Overview](#overview)
- [Defaults](#defaults)
- [Development](#development)
- [Troubleshooting](#troubleshooting)

## Overview

Expand Down Expand Up @@ -45,6 +45,7 @@ services:
# - MJML_KEEP_COMMENTS=true
# - MJML_VALIDATION_LEVEL=strict
# - MJML_MINIFY=false
# - MJML_BEAUTIFY=true
```

## Defaults
Expand All @@ -56,6 +57,7 @@ CORS ""
MJML_KEEP_COMMENTS "false"
MJML_VALIDATION_LEVEL "soft"
MJML_MINIFY "true"
MJML_BEAUTIFY "false"
```

## Development
Expand All @@ -67,6 +69,7 @@ CORS "*"
MJML_KEEP_COMMENTS "true"
MJML_VALIDATION_LEVEL "strict"
MJML_MINIFY "false"
MJML_BEAUTIFY "true"
```

This will escalate any issues you have with invalid mjml code to the docker log (`stdout` or `docker-compose logs`).
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ app.use(bodyParser.text({
const opts = {
keepComments: (process.env.MJML_KEEP_COMMENTS === 'true'),
minify: (process.env.MJML_MINIFY === 'true'),
beautify: (process.env.MJML_BEAUTIFY === 'true'),
validationLevel: (['soft', 'strict', 'skip'].includes(process.env.MJML_VALIDATION_LEVEL) ? process.env.MJML_VALIDATION_LEVEL : 'soft'),
}

Expand Down Expand Up @@ -81,5 +82,6 @@ console.log('cors: ' + (process.env.CORS || 'n/a'))
console.log('mjml keep comments: ' + opts.keepComments)
console.log('mjml validation level: ' + opts.validationLevel)
console.log('mjml minify: ' + opts.minify)
console.log('mjml beautify: ' + opts.beautify)
console.log('')
console.log('POST mjml as text/plain raw body, result will be returned as text/html.')