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

Add a way to render html strings inside element in jsx components #127

Closed
mairatma opened this issue Jun 10, 2016 · 7 comments
Closed

Add a way to render html strings inside element in jsx components #127

mairatma opened this issue Jun 10, 2016 · 7 comments

Comments

@mairatma
Copy link
Contributor

It's currently possible to render html strings via Metal.js soy components, but not via jsx components.

This was requested by @mthadley and @bryceosterhaus. Today they're going around this by using incremental dom directly, like this.

@mthadley
Copy link

For ease of reference:

render() {
  IncrementalDOM.elementOpen('div', null, null, 'class', 'my-html-string-container');
  const node = IncrementalDOM.elementClose('div');
  node.innerHTML = '<div class="my-html-string">Hello World!</div>';
  return node;
}

@mairatma
Copy link
Contributor Author

mairatma commented Jul 5, 2016

This issue was moved to #9

@mairatma mairatma closed this as completed Jul 5, 2016
@mairatma
Copy link
Contributor Author

This issue was moved back.

@bryceosterhaus
Copy link
Member

Looks like the easiest way is to make that change in incremental-dom, but that would also affect soy. Should we do that, or find a way to make this change specifically on the JSX side of metal?

@eduardolundgren
Copy link
Contributor

@bryceosterhaus We might be able to to that for both JSX and Soy. If you have more details about how this can be achieved let me know.

@mairatma
Copy link
Contributor Author

Just FYI, at the time I remember I was thinking of just making a jsx component that could handle this, not of changing anything in metal.js itself. The component could even use html2incdom to turn the inner html into incremental dom calls, or in the simplest case just do the same thing @mthadley posted here in its render function.

Not sure that's what you really need right now, just wanted to explain in case it might be of help :)

@bryceosterhaus
Copy link
Member

I was trying to avoid just creating a component for it because its just an additional thing to import. So I was hoping to implement it in babel-plugin-transform-incremental-dom since its just the jsx side so i asked there and it was recommended to add it to our iDOM configuration but after testing that with our specific metal implementation there were issues with updates and patching. I tried testing an implementation it in iDOM by itself and seems to be that trying to set 'innerHTML' just doesn't work for our case.

So in the end, looks like the best route is to just create a component for this. I'll go ahead and create one and send a pr.

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

No branches or pull requests

4 participants