I am experimenting with fetching json object then display the content from a remote Wordpress. The issue I am running into and can’t find the answer is how do I get rid of the HTML tag like <p>
tag when it render on the app?
Show an example of data you have and the data you want
This is the json results:
"<p>Lorem ipsum dolor sit amet <\/p>\n"
and it get printed out with the <p>
tag
This is what the app look like: https://goo.gl/dj6gLp
Hey Leon! Since Fuse is not HTML-based, it will simply treat this as raw text, with tags included and all. You’ll have to remove them manually, either by parsing it yourself or using some other JS-based HTML parser. The quickest solution is probably just basic textual replacement on the string if you only have a few different kinds of tags coming in.
Yea use Regex:
function stripHTML(text) {
return text.replace(/<.*?>/gm, '');
}
stripHTML("<p>Lorem ipsum dolor sit amet <\/p>\n"); // Lorem ipsum dolor sit amet
Jake Taylor wrote:
Hey Leon! Since Fuse is not HTML-based, it will simply treat this as raw text, with tags included and all. You’ll have to remove them manually, either by parsing it yourself or using some other JS-based HTML parser. The quickest solution is probably just basic textual replacement on the string if you only have a few different kinds of tags coming in.
Jake,
Thank you for the tip and clarification! I’ll see what I can do and come back with the results.
Big fan of all your videos tutorials!
Edwin Reynoso wrote:
Yea use Regex:
function stripHTML(text) { return text.replace(/<.*?>/gm, ''); } stripHTML("<p>Lorem ipsum dolor sit amet <\/p>\n"); // Lorem ipsum dolor sit amet
Edwin, thanks! I’ll give this a try and let you know!
Leon wrote:
I am experimenting with fetching json object then display the content from a remote Wordpress. The issue I am running into and can’t find the answer is how do I get rid of the HTML tag like
<p>
tag when it render on the app?
Hi Leon, I believe you could come up with working example fetching data using wordpress rest api. If yes can you please guide us through…
Thank you for your support…
Leon wrote:
Jake Taylor wrote:
Hey Leon! Since Fuse is not HTML-based, it will simply treat this as raw text, with tags included and all. You’ll have to remove them manually, either by parsing it yourself or using some other JS-based HTML parser. The quickest solution is probably just basic textual replacement on the string if you only have a few different kinds of tags coming in.
Jake,
Thank you for the tip and clarification! I’ll see what I can do and come back with the results.
Big fan of all your videos tutorials!
Hi Jake …
Your videos are amazing … I am also big fan of all your videos.