-
-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for mj-include tags #48
Comments
@pareeohnos Sounds like a cool idea. Do you have a sample repo with the problem you could push somewhere? Could you use mj-raw for it? Sounds like it would be better solved in the VSCode extension... is it similar enough to this one? attilabuti/vscode-mjml#55 |
I don't currently but I'm sure I could put something together for it. I can ask the dev of the VSCode project, but I didn't have any issues with that when using |
@pareeohnos I'm not sure I quite understand the problem yet - so I was just grasping at straws with the |
heh sorry I probably explained it really badly - I'll try and throw something together :) |
@pareeohnos not at all... my brain just works best when there's code to dig into. |
@sighmon yeah I'm much the same, code is a lot easier to follow. I've put an example here https://github.com/pareeohnos/mjml-vscode-issue I couldn't get it to produce the error messages for some reason but the issue itself is still visible. If you install the vscode extension and open the If I swap out the |
@pareeohnos Brilliant thanks. Which VSCode extension are you using?
When I use MJML v1.6.0 I see the error you're talking about. This line is commented in the output: <!-- mj-include fails to read file : ../layouts/email_body_common.mjml at /var/folders/xx/yxxxxxxxxxxx...xxxxxxxxgp/layouts/email_body_common.mjml --> I'll keep poking around a bit. :-) |
@pareeohnos I get the feeling we might need to solve it in a similar way to: https://github.com/mjmlio/mjml#inside-nodejs And hand in a |
@sighmon I've got the same versions as you, should all be the latest I think. |
@pareeohnos I'm not going to get to work on this for a little while - did you want to put together a pull request? |
Sure no problem, I'll see if I can find some time to put something together but it might also be a while. I'm not currently working on this part of our system as I just got it working using normal rails layouts so will need to refactor and try it again at some point |
Bumping this issue up. To summarize, You can set the path to a correct absolute value, but this breaks editor-preview. By example, this fixes the Rails error: I believe the solve here is for mjml-rails to pre-process the include paths and expand them to absolute before parsing. |
PR Submitted #100 |
Not sure if this is actually possible within rails as it may be related more to how rails processes templates than with the gem itself, but I was wondering if it was possible to fully support the
mj-include
tag within views.The gem provides the usual rails ability to use an email layout and
yield
the individual mail templates which is great, however I'm using an extension for Visual Studio Code which lets me view previews of the emails as I write them which is extremely helpful. Unfortunately because this extension uses just plain mjml it doesn't work with the rails template loading so it almost immediately fails to render emails due to them being invalid, or they're not complete.To get around the preview issue I was trying to use
<mj-include>
instead which was working well, however when it came to rendering an actual email, mjml threw out errors about not being able to find the included file because it was now all in the/tmp
directory somewhere. I was forced to then go back to using the rails template stuff which is fine and it works and I can use theActionMailer::Preview
classes to generate previews, but it is faster having it instantly render in my editorThe text was updated successfully, but these errors were encountered: