sighmon / mjml-rails

MJML + ERb/Haml/Slim view template
https://mjml.io
Other
300 stars 65 forks source link

Change default validation level to `strict` and honor `validation_level` #72

Closed doits closed 3 years ago

doits commented 3 years ago

Note: This is based on top of #71. Please first look at #71, so hopefully #71 can be merged and then there will be fewer changes here. Then you can take a look at this one.

Second note: If this is merged and released, there should be a major version bump (I'd say 4.5) with a changelog entry, because it is a possible backwards incompatible change if somebody has:


Before this commit MJML-Rails always raised an exception if there is any template validation error.

In MJML there are two validation levels though (besides disabling validation completely):

Right now it does not matter what validation level is used in MJML-Rails: It always raises an error if something is wrong with the template, which actually makes the setting MJML.validation_level superfluous.

With this commit, MJML-Rails follows the MJML convention to only abort if the validation level is strict. If it is soft, it lets MJML do what it can and only logs the errors, like MJML does.

To prevent apps using the default configuration from breaking, the default validation level is changed to strict, too. This means it raises an error on an invalid template like it did before.

sighmon commented 3 years ago

@doits Looks good, thanks.