sighmon / mjml-rails

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

Allow developer to specify templating language they use #6

Closed mswiszcz closed 7 years ago

mswiszcz commented 7 years ago

Hey guys.

With this little change developers may specify in any config file (for ex. config/initializers/mjml.rb) templating language they are using, and it should work properly basically for all available templating languages.

Config file should look like this:

Mjml.setup do |config|
  config.template_language = :slim # :erb (default), :haml, or any other you are using
end

Hope this little change proves to be useful, if you have any ideas to improve this do not hesitate to let me know or update the PR 😄 It kind of solves #3 :wink:

I was looking for better solution, so developer just had to add .slim, or .haml extension to .mjml file, without having config file, but wasn't able to make it work - if anyone has any idea I would be happy to collaborate on this.

For syntax highlighting, I myself use atom with file-types addon and it looks and works awesomely, proof:

screen shot 2016-10-03 at 23 17 14
sighmon commented 7 years ago

@mswiszcz I ran out of time to merge this today.. but it looks like a decent idea. Thanks for the PR - I'll check it through with @thatpixguy and let you know.

tylerhunt commented 7 years ago

I was looking for better solution, so developer just had to add .slim, or .haml extension to .mjml file, without having config file, but wasn't able to make it work

@mswiszcz I'm curious what issues you ran into here. I've been using MJML::Rails with Haml for a while now (at least the 2.2.0 version) by using a .mjml.haml extension, and it's been working just fine. It should process them from last to first, so Haml would be converted to HTML, and then the HTML would be run through MJML.

Here's an extract showing what the Haml template with MJML tag looks like:

%mj-text{ mj: { class: 'body-text' } }
    %p Body text.