0
Good afternoon, I’m not sure if that’s the most appropriate title...
I’m using Meteor and mongodb.
I have 2 input, one where I type the name of the site and the other I type the site "www.exemplo.com.br", which then in javascript I have the following:
var siteCad = '<a href="http://'+ site +'">' + nome + '</a>';
Then I insert the siteCad inside a MongoDB Collection. I would like to show all these links within a <.li> but what is happening is that it shows the whole text, from the <.a href... to the "dot and comma", I want to show the link directly, as if it were directly from html.
In short, I have html tags with properties filled in in mongoDB in string format and would like to move to html.
Does anyone have any example or reference that I can take a look at?
In general it is not a good idea to generate HTML using string concatenation as you are doing. You are vulnerable to Javascript injections (XSS) if the user puts html tags in the name or an "onhover" in the site field.
– hugomg
And why do you want to insert HTML into the database? Wouldn’t it be better to insert a record with the name and the site and generate the html later?
– hugomg
is what I’m thinking now, but I don’t know how to insert the site in href there in the html there, I’m starting the studies in Content actually. How would I set a variable in href?
– henrique
If I try to do this: <a href={site}}>, it just doesn’t work.
– henrique