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
Use with other template languages (Rails, Phoenix, etc) #346
Comments
edit: This actually removes quotation from a large number of attributes where it should exist, back to the drawing board. I had a moment to dig into PostHTML a little and came up with the following:
which does correctly give me the output:
Is this a reasonable approach? |
This seems to be another possible approach by using
|
Hey, Normally it should just work with PostHTML's posthtml: {
options: {
directives: [
{ name: '%=', start: '<', end: '>' }
],
}, For some reason it doesn't though, it still outputs something like I've tested thoroughly and I can't see it coming from other parts of Maizzle - I disabled all transformers and anything else that might manipulate HTML, even tested with all PostHTML plugins removed when rendering with PostHTML. What's really weird is that if you modify this test in PostHTML to work with these @Scrum do you have any insight as to why it wouldn't work with |
@bradleybeddoes a quick solution would be to use some made-up tags/delimiters that you then replace with <h1>Hi, !%= @user.name %!</h1> replaceStrings: {
'!%=': "<%=",
'%!': "%>",
}, |
Looks like it's fixed in I'll release a patch for Maizzle once this and this PR get merged and those two plugins each get a patch release. @bradleybeddoes for now, you can remove |
Thank you so much for your help with this @cossssmin 🏆 I can confirm that by removing |
Happy to help :) Tip: you don't need the |
@bradleybeddoes published |
@cossssmin I'm actually still seeing this on a new Maizzle install. Been fighting it the past two days but I'm at wits end.
@bradleybeddoes You're not still having issues with this?! |
No problems here, update fixed my issue completely 🤔. |
@bradleybeddoes do you mind sharing your config.js? Can't understand why I'm still seeing this. |
Can confirm it's an issue with Maizzle 3.0, I think this bug has multiple causes. Could be For example, with inlining enabled, this: <title><%= @title %></title> ... is rendered as: <title><%= @title %></%=>
</title> If you disable CSS inlining however, you get: <title><%= @title="" %=""></%=></title> If we use a <div><%= @title %></div> ... it's rendered as expected, but only if inlining is enabled. Otherwise it renders as You could still use the |
Thanks @crosssmin, I am utilizing replaceStrings with some luck replaceStrings: {
'%=""></%=>': "%>",
'=""': "",
}, but there's other instances, even with all applicable transformers disabled, where thing are still getting mangled, like this line: <% if ((attachments && attachments['doc_thumb.jpg']) || @email_record) && content_for?(:document_url) %> is being output as: <% if ((attachments && attachments['doc_thumb.jpg']) || @email_record) content_for?(:document_url) %> (notice the missing Until a fix where everything between the delimiters is completely ignored, this will be a tough one to crack. |
Confirm, the problems are related to the update |
i checked on current posthtml version and i get expected result const posthtml = require('posthtml') // "posthtml": "^0.14.0"
const html = `<title><%= @title %></title><div><%= @title %></div>`;
const plugins = [];
const options = {};
posthtml(plugins)
.process(html, options)
.then((result) => console.log(result.html)) // => <title><%= @title %></title><div><%= @title %></div> |
@Scrum hmm, I suppose it's caused by plugins then? $ npm list posthtml-parser
@maizzle/framework@3.0.0 F:\DEV\open-source\maizzle\framework
+-- posthtml@0.14.0
| `-- posthtml-parser@0.6.0
+-- posthtml-expressions@1.6.2
| `-- posthtml-parser@0.5.3
+-- posthtml-extend@0.5.2
| +-- posthtml@0.13.4
| | `-- posthtml-parser@0.5.3 deduped
| `-- posthtml-parser@0.5.3
+-- posthtml-fetch@1.2.0
| `-- posthtml@0.13.4
| `-- posthtml-parser@0.5.3
+-- posthtml-markdownit@1.2.2
| +-- posthtml@0.13.4
| | `-- posthtml-parser@0.5.3 deduped
| `-- posthtml-parser@0.5.3
+-- posthtml-mso@1.0.2
| `-- posthtml@0.13.4
| `-- posthtml-parser@0.5.3
+-- posthtml-postcss-merge-longhand@1.0.2
| `-- posthtml@0.13.4
| `-- posthtml-parser@0.5.3
+-- posthtml-safe-class-names@1.0.4
| `-- posthtml@0.13.4
| `-- posthtml-parser@0.5.3
`-- posthtml-url-parameters@1.0.4
`-- posthtml@0.13.4
`-- posthtml-parser@0.5.3 |
@cossssmin Maybe. Each plugin can render / parse a tree and return a mutated one |
Yeah, gonna have to start updating them all to use the latest |
@cossssmin |
@chasegiunta published You'll need to delete your |
@cossssmin Perfect. Looks like that works! Thank you for you help! |
Awesome, closing as resolved then 👍 |
I wonder if anyone here would be willing to share how they've integrated Maizzle with their backend framework - both in a conceptual sense but also what a config file might look like. I'm trying to see how best to fit Maizzle into a Rails app and integrate it with ActionMailer. Would be super interesting as a blog post. |
Hi guys do you have sample integration for Phoenix Framework? Thank you. |
Firstly many thanks for your efforts in building Maizzle and helping out the community.
I've scoured the docs, issues and PR looking for an answer to this, apologies if I've just stupidly overlooked something simple here.
What I am trying to do is have my email content designed in Maizzle but for transactional email push the build results into my web app as templates for its template engine to consume when deployed in production, the template languages seem to be colliding however.
An example might make this easier to visualise, what I am trying to do is make this:
Output (for a
prod
configuration build) as:instead the output is:
As you can see the output inside
h1
is "corrupted" by something internally "trying to do the right thing" when what I was hoping to get withraw
was the block being entirely untouched in the output.As you'd expect I get
<h1>Hi, Fred</h1>
perfectly fine when serving locally usingmaizzle serve
Here is my
config.prod.js
if helpful, I have tried a number of angles to solve this so it is getting a touch messy by now:Any help on solving this would be really appreciated.
The text was updated successfully, but these errors were encountered: