Skip to content
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

renderMJML children #914

Closed
maxs15 opened this issue Dec 10, 2017 · 6 comments
Closed

renderMJML children #914

maxs15 opened this issue Dec 10, 2017 · 6 comments
Labels
Milestone

Comments

@maxs15
Copy link

maxs15 commented Dec 10, 2017

I'm trying MJML 4 and I can't render the children of my custom component.
Here is what I'm doing, am I doing something wrong ?
Sorry if I'm missing something, always hard without doc ;) Thanks for the help.

Custom component

class Layout extends BodyComponent {

	render() {
		return this.renderMJML(`
			<mj-section>
				<mj-column>
					${this.renderChildren(this.props.children)}
				</mj-column>
			</mj-section>
		`)
	}

}

mjml template:

<mjml>
	<mj-body>
		<layout>
			<mj-text>TEST</mj-text>
		</layout>
	</mj-body>
</mjml>
@iRyusa
Copy link
Member

iRyusa commented Dec 10, 2017

Hi @maxs15

I think this is because mj-column can't receive plain HTML ( this.props.children will already be rendered when passing it into the mj-column ). I think this is something we didn't had in mind when creating this feature. We might need some kind of rawChildren that would allow this kind of thing.

@iRyusa iRyusa added the MJML 4 label Dec 10, 2017
@maxs15
Copy link
Author

maxs15 commented Dec 11, 2017

Hey @iRyusa,

Ok I see what's the issue, rawChildren would be a handy property indeed.
I hope you will consider added it in the next release, there's unfortunately lot of things that I can't do without that.

Thanks, and good work on MJML 4 🎉

@iRyusa
Copy link
Member

iRyusa commented Dec 11, 2017

ATM you can actually convert your JSON as XML with this snippet : https://jsfiddle.net/jp1nfsk0/ I think it should work fine 👍 Can you try it ?

@maxs15
Copy link
Author

maxs15 commented Dec 11, 2017

Awesome it works ! I'm gonna use that for the time being 👍
You could actually expose such a method in the BodyComponent class (renderRawChildren for instance)

@iRyusa
Copy link
Member

iRyusa commented Dec 11, 2017

Yeah I think it will either be exposed as an helper method or as you said on BodyComponent, we'll talk about this 👍

@iRyusa
Copy link
Member

iRyusa commented Jan 23, 2018

@kmcb777 Can you add an option on renderChildren func to get the raw XML version and allow this for the next beta ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants