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

Render Field as HTML #38

Open
AmitSonkhiya opened this issue May 17, 2023 · 3 comments
Open

Render Field as HTML #38

AmitSonkhiya opened this issue May 17, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@AmitSonkhiya
Copy link

Is there a way to render markup as is (HTML) from the specific property of self object?

Use case:
The API returns HTML in one of the JSON object's property.
However, Lemonadejs renders it as the inner text.
I would like it to render the HTML as is.

Through I can manually update it later on using Vanilla JS code but that doesn't seem handy enough as well as tedious to manipulate with update or other events.

{
      "name": "Eternal Flame",
      "age": 25,
      "secret": "Unknown",
      "about": "<h3>About section</h3><span class="\date-time\">17 May 2023<span>"
}

I would like about field to render as HTML rather as text.

@hodeware
Copy link
Contributor

hodeware commented May 17, 2023

We are checking to see the availability. But there are alternatives....

@hodeware
Copy link
Contributor

self.whenReady = function(obj) {
      self.about.innerHTML = obj.about;
}
self.call = function() {
    self.whenReady({
      "name": "Eternal Flame",
      "age": 25,
      "secret": "Unknown",
      "about": "<h3>About section</h3><span class="\date-time\">17 May 2023<span>"
    })
}

What you can do:
<div :ref="self.about"></div>

@hodeware hodeware reopened this May 19, 2023
@hodeware hodeware added the enhancement New feature or request label May 19, 2023
@AmitSonkhiya
Copy link
Author

AmitSonkhiya commented May 22, 2023

Thank you and have further questions.
The data is returned by the server and and I'm using it in a loop with lemonade.render().
So it is not a static object as given in the whenReady example.

How to I perform self.call() to run automatically within the loop and update with the correct index. I have the original object but I don't feel it is a friendly way to render HTML with manual loop code. Can't the self object itself contain a special property having the list of fields to render as HTML (like starting with an underscore, self._html = ['about', 'entry_time'])?

Also, I suspect this will first display the markup for a while and render HTML later which seems bit ugly unless there is an invisible class on the element itself.

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

No branches or pull requests

2 participants