Insert HTML markup using Meteor - html

How can I display marked up string data in a Meteor template?
I need to display a string from my database that contains some basic HTML tags such that the resulting text is properly formatted. It currently just displays the markup text.
Here's the relevant part of the template:
<span class="description">{{description}}</span>
Where {{description}} is the string containing markup (like "hello<br>world").
I'd like it to display
hello
world
rather than
hello<br>world
I guess this would be similar to using innerHTML in javascript.
Thanks in advance!

To override HTML-escape in Handlebars, use the triple-stash:
<span class="description">{{{description}}}</span>

Related

Getting a HTML template as a HTML string

consider that I have several HTML templates and they have custom HTML tags. For ex: c-icon, c-text, c-button etc.
For some usecase(Display other content along with innerHTML), I need to access c-icon tag HTML inside c-text and append it to some text so that I can render it with some other html text. In future, I may have another component called c-badge and even I want to refer and render.
Could you please provide any suggestions for achieving the same?

Angulardart show HTML String

This question is probably really stupid but i really searched a lot for it, but I may be using the wrong keywords.
I have a String with <hr> and I want Angular to display a horizontal line.
The HTML is converted to <hr> and therefore displayed as text <hr> on the page.
How can I achieve this that the HTML tags are not converted by angular?
I have done this in Angular 6 with TS and there it was no problem, is there a pipe or something else, which I have to use?
Binding to [innerHtml] should do that.
<div [innerHtml]="fieldInComponentClassWithHtml"
You need to use SafeInnerHtmlDirective
https://pub.dev/documentation/angular/latest/angular.security/SafeInnerHtmlDirective-class.html

Meteor {{#markdown}}

I am making a forum with markdown support.
I've been using meteor's markdown parser {{#markdown}} and have found something disturbing that I can't seem to figure out.
I am using {{#markdown}}{{content}}{{/markdown}} to render the content inserted into database.
The disturbing thing, for example, if someone writes up html without inserting it into the code block in the content...
example
<div class = "col-md-12">
Content Here
</div>
This will render as a column. They could also make buttons and etc through writing the HTML for it.
How to disable this behaviour so that when HTML is written it will not render into HTML but just simply show it as text?
You can write global helper, which will strip all html tags:
function stripHTML(string){
s = string.replace(/(<([^>]+)>)/ig, '');
return s;
}
Template.registerHelper('stripHTML', stripHTML)
Usage :
{{#markdown}}{{stripHTML content}}{{/markdown}}
Test it in console:
stripHTML("<div>Inside dive</div> Text outside")

tinymce : how to convert raw html tags?

i used tinymce to allow people to write content. But now i wan't them to edit their own content, i need to use tinymce again.
My problem is in my database, this content is composed of html tags, and when i try to load the text in my tinymce textarea (in edit view), i've got the raw content eg <p> Hello my name is <em>John</em> [...] </p> . But when they written this content, it was with "wysiwyg".
I want to convert this raw html to wysiwig.
here a screenshot of the raw html
and i want it to be like this when they click on "edit my content" button :
I use this:
echo <textarea name="icerik" id="editor1" rows="10" cols="80">'.htmlentities($satir->icerik).'</textarea>;
I use "htmlentities" method in php to convert html code to wysiwyg. When you write that converted text between and , you can get what you want.
Assuming you're using PHP of course. If not, try to search like for example "htmlentities in asp.net" or wait for another answers.
tinyMCE.activeEditor.setContent('<span>html data from your database</span>');
Use this:
strip_tags(stripslashes('row html content'))

Show html code as rendered html text

I am trying to take some input from the user with the wisywig text editor plugin. But, when I try to show the text in a label or paragraph, all the html tags become visible.
For example,
#string str = "<b>sample text</b>";
<label>#str</label>
should look like
sample text
But it is not. It looks like,
<b>sample text</b>
How can I render a html code string into a html text...???
i am working with .net mvc3 with razor view engine...
That may happen if HTML entiries are being encoded.
You need to avoid that encoding or do decoding. For example, in PHP you can use http://php.net/manual/en/function.html-entity-decode.php to decode HTML entities.