I allow users to embed videos from Youtube, Google, Vimeo, etc. I was thinking of the best and safest approach (I do not want them to be able to include any flash memory, and I also want to limit the video to exclude free porn sites, etc.).
Therefore, I thought that it’s best and easiest to let the user simply copy and paste the video URL into a text box, save it in the ExternalVideo model and then simply generate the necessary HTML code for embedding the video.
So, my ExternalVideo model has a function called "embed_html" that should return the correct HTML.
Of course, I could do something like this:
def embed_html
"<embed src='#{@video_source}'>"
end
But I think that is bad practice and very unreadable.
My question is: is there a / Gem / built-in function that I can use to create custom HTML, something like View Helpers (link_to, image_tag, etc.)?
Thank you for your help!
source
share