![]() ![]() In Rails this is done through the Action Mailer Layouts. If you have different kinds of emails in your project, you might want to extract some of the shared logic into something you could reuse (“Don’t Repeat Yourself!”). After working with it for a while in some of our other projects and with the recent upgrade of the language to version 3, we thought that it’s time for an update! Use MJML in a Rails Email Layout Setup I think by now this can be considered "beta", though please test on your local environment first and let me know if you notice anything.Last year, our colleague Hugo Giraudel wrote a blog post about integrating MJML into Rails. TracyDebugger hooks to `render` as well and thus some of its markup might end up in the converted code when showing the `raw` version. I also added a small note in the settings regarding TracyDebugger to invite module users to disable the panel bar for the MJML templates. My current use-case for this is having a "browser" version (with ?browser) where I can display a newsletter with the right webfont. `raw` is ignored as it’s used by the module. Please note though that, when rendering, if there are several GET variables only the first one is used. Previously a GET variable would just output and save to the page’s cache but now you can specify GET variables (or the wildcard "*") to have a cached version per variable. The second one is more interesting as it adds the ability to generate a unique output per GET variable. I don’t think it will be used much but it’s there in case the cache invalidation when saving the page or updating the template’s file is not enough The first one adds the ability to select specific roles to bypass the cache and thus convert the MJML code on each page render. I pushed a new version with two additions: #34 /home/aca/ProcessWire\WireHooks->runHooks() #33 /home/aca/ProcessWire\Wire->_callMethod() #32 /home/aca/ProcessWire\ProcessPageView->_execute() #31 /home/aca/ProcessWire\ProcessPageView->renderPage() #29 /home/aca/ProcessWire\WireHooks->runHooks() #27 /home/aca/ProcessWire\WireHooks->runHooks() #26 /home/aca/ProcessWire\Wire->_callMethod() #25 /home/aca/ProcessWire\PageRender->_renderPage() #23 /home/aca/ProcessWire\WireHooks->runHooks() #22 /home/aca/ProcessWire\Wire->_callMethod() #19 /home/aca/require('/home/aca/#20 /home/aca/require('/home/aca/#21 /home/aca/ProcessWire\TemplateFile->_render() #17 /home/aca/ProcessWire\WireHooks->runHooks() #16 /home/aca/ProcessWire\Wire->_callMethod() #15 /home/aca/ProcessWire\ProcessController->_execute() #13 /home/aca/ProcessWire\WireHooks->runHooks() #12 /home/aca/ProcessWire\Wire->_callMethod() #11 /home/aca/ProcessWire\ProcessPageEdit->_execute() #10 /home/aca/ProcessWire\ProcessPageEdit->renderEdit() #8 /home/aca/ProcessWire\WireHooks->runHooks() #7 /home/aca/ProcessWire\Wire->_callMethod() #6 /home/aca/ProcessWire\PageMjmlToHtml->addViewRaw() #3 /home/aca/ProcessWire\WireHooks->runHooks() #1 /home/aca/ProcessWire\Page->_callUnknown() #0 /home/aca/ProcessWire\Wire->_callUnknown() If your layout looks weird somehow, try disabling the minification in the options.ĭEBUG MODE BACKTRACE ($config->debug = true): This option is available in the module’s settings. If you are using the markup regions output strategy, it might be best to not append files to preserve your MJML markup before calling the MJML API. ![]() Its title and a message inviting to contact the administrator for editors If there’s an error the page will display: The code viewer is only shown to superusers. Only visible to users with the page’s edit permissionĪ shortcut is also added under “View” in the edit page to open the raw code in a new tab Not added if the page is rendered outside of a PageView The MJML output is cached to avoid repetitive API callsĬleared if the template file has been modifiedĪ simple (dumb?) code viewer highlights lines with errors/warningsĪ button is added to quickly copy the raw code of the generated newsletter You will either get error/warning messages or your email properly formatted and ready-to-go.įrom there you can copy/paste the raw generated code in an external mailing service or distribute your newsletter using ProMailer. Once your credentials are validated, select the template(s) in which you’re using the MJML syntax, save and go visualize your page(s) to see if everything’s good. Write your template using MJML combined with Processwire’s API and this module will automatically convert your code into a working newsletter thanks to their free-to-use Rest API.įor this module to work you will need to get an API key and paste it in the module’s configuration. A module allowing you to write your Processwire template using MJML and get a converted HTML output using MJML API.Ĭreated by Mailjet, MJML is a markup language making it a breeze to create newsletters displayed consistently across all email clients. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |