hardpixel / mrml-ruby

Ruby wrapper for MRML, the MJML parser implementation in Rust.
MIT License
47 stars 7 forks source link

MRML validate #8

Open autonomous opened 8 months ago

autonomous commented 8 months ago

Is your feature request related to a problem? Please describe. When building mjml templates errors sometime sneak in. The templates are often large/complex, and a debugging what the root cause of the error is is difficult.

Describe the solution you'd like I'd like to pass a template string to a MRML validate method, and it returns a collection of the errors it has encountered. An output similar to what mjml-cli -v produces would be amazing:

$ mjml -v malformed.mjml
Line 8 of test.mjml (b) — Element b doesn't exist or is not registered

Command line error:
Validation failed

... for example:

errors = MRML.validate("...")
[
  "Line 8 (b) - Element b doesn't exist or is not registered",
  ...
]

Is this something you'd be open to?

jonian commented 8 months ago

Hi @autonomous, thanks for the report. The mrml rust library does not provide a validate method. You can open an issue there and if it gets implemented I will add it to mrml-ruby.