monollonom Posted June 11, 2023 Author Share Posted June 11, 2023 Following the previous addition to convert relative URLs into absolute ones I quickly needed to ignore some that weren’t just starting with either "http", "tel" or "mailto" but were also keywords from mailing tools such as "*|UNSUBSCRIBE|*". However I also did some changes in the module’s config, mostly for clarity but also to avoid a call to the MJML API on every save. So before I publish a new release, I wouldn’t mind if any users (@wbmnfktr, @szabesz?) would try it out in a local environment and confirm everything is still working (it is on my side) before I create a new release and update it in the module directory. Thanks! 1 Link to comment Share on other sites More sharing options...
szabesz Posted June 11, 2023 Share Posted June 11, 2023 (edited) Hello @monollonom, I updated the site I'm using this module of yours from v1.1.8 to the this RC version and could not notice any difference. I do not know if it makes any difference or not, but I'm using the module with the "Bypass cache for superusers?" option turned on, because as a superuser, I will ever be the only one to have the module convert MJML to HTML. It is because I am using it for generating HTML templates for transactional emails which are only changed by me. I implemented a simple interface in the admin for rendering and previewing requested MJML templates which are first saved as HTML files and after that parsed for some simple "custom template tags" I made up, so that tags can be populated with actual values and the whole email can be sent in the end. So these MJML templates rarely change (except during development, of course) and that's why I do not use caching at all. When sending a transactional email, its saved HTML template is used. cheers Szabesz Edited June 11, 2023 by szabesz 1 Link to comment Share on other sites More sharing options...
wbmnfktr Posted June 12, 2023 Share Posted June 12, 2023 So... I updated to the version you linked in your post. No errors while updating. New module settings page looks great and works as expected so far. I added query paramters just to test them: And got this: Only updated relative links are affected - as far as I can see right now. 1 Link to comment Share on other sites More sharing options...
monollonom Posted June 12, 2023 Author Share Posted June 12, 2023 (edited) 3 hours ago, wbmnfktr said: And got this: Only updated relative links are affected - as far as I can see right now. Ah! You uncovered my evil plan to put my website on every newsletter generated from my module ? Joke aside, thanks for spotting this one, it was because of $page->getText returning an empty string when there were no {brackets} in the string. I also spotted another bug if you left the "ignore" textarea empty. Here’s the updated file. Let me know if you notice anything else and otherwise I’ll publish the release! Edit: noticed and fixed another small issue with slashes (if missing in the custom host, or if the relative url doesn’t start with one) 14 hours ago, szabesz said: I do not know if it makes any difference or not, but I'm using the module with the "Bypass cache for superusers?" option turned on, because as a superuser, I will ever be the only one to have the module convert MJML to HTML. It is because I am using it for generating HTML templates for transactional emails which are only changed by me. It shouldn’t make any difference indeed but thank you anyway for sharing your usage of the module! Edited June 12, 2023 by monollonom 1 1 Link to comment Share on other sites More sharing options...
wbmnfktr Posted June 12, 2023 Share Posted June 12, 2023 12 minutes ago, monollonom said: Ah! You uncovered my evil plan to put my website on every newsletter generated from my module ? A small step to world domination! Love the idea. ? So, just updated the file, tested again, added a {bracket} value. No issues. Everything works as expected! 1 Link to comment Share on other sites More sharing options...
monollonom Posted June 12, 2023 Author Share Posted June 12, 2023 Alright, latest version is now published and available through the Upgrade module. Thanks again! 1 1 Link to comment Share on other sites More sharing options...
cpx3 Posted September 5, 2023 Share Posted September 5, 2023 Hi @monollonom, thanks for the great module. I just have a strange problem: when I try to preview the rendered page as a guest user, I can only see <h1>title</h1> and the rest disappears it seems the module cannot be used to create a "view in browser" version, right? Ok, just saw that the editor says that "align is illegal", but it works perfectly with the normal MJML app... Link to comment Share on other sites More sharing options...
monollonom Posted September 5, 2023 Author Share Posted September 5, 2023 If you don’t see an output as a guest user it means there was an error trying to convert the MJML code. 4 hours ago, cpx3 said: Ok, just saw that the editor says that "align is illegal", but it works perfectly with the normal MJML app... Is there a way you could share your code? A screenshot maybe? Link to comment Share on other sites More sharing options...
monollonom Posted Monday at 08:30 PM Author Share Posted Monday at 08:30 PM I just published an update that might be of interest to some: the ability to transpile any MJML code without it being part of a template. From the release note: This new release extracts the transpiling of MJML to HTML into its own public method allowing you to call it for any arbitrary piece of MJML code, instead of having to have the code in a template file: $mjml = "<mjml></mjml>"; /** @var PageMjmlToHtml $pmh */ $pmh = $modules->get("PageMjmlToHtml"); $result = $pmh->transpile($mjml); if($result->code === 200 && empty($result->errors)) { echo $result->html; } By default the options’ values are the ones set in the module’s settings. This new method is also hookable, which means you can for example set different options depending on the template: $wire->addHookBefore("PageMjmlToHtml::transpile", function(HookEvent $event) { $mjml = $event->arguments(0); /** @var Page $page */ $page = $event->arguments(1); $options = $event->arguments(2); if(!$page->id || $page->template != "specific-template") return; $options["relativeLinksParams"] = "utm_campaign=new-campaign-title"; $event->arguments(2, $options); }); 1 1 Link to comment Share on other sites More sharing options...
szabesz Posted Monday at 08:43 PM Share Posted Monday at 08:43 PM 11 minutes ago, monollonom said: that might be of interest to some Great new features, thanks a lot! 1 Link to comment Share on other sites More sharing options...
monollonom Posted Monday at 09:05 PM Author Share Posted Monday at 09:05 PM (I forgot to update the download link on the PW modules website, it should be good now!) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now