Html rendering for template

Hi devs,

I’m using a helper that will fetch text from my database to stylize it with HTML tags.

However when I call the value returned by the helper in my template, html tags are visible like text as it is a string.

Is there a way to make my template or my return value in innerHtml?

transformContentCorrection(contentCorrection) {
		
		let contentTicket = Tickets.findOne({_id: FlowRouter.getParam('ticketId')}).content
		contentCorrection = this.content
			
		let diffs = diff_match_patch.prototype.diff_main(contentTicket, contentCorrection)
		
		let prettyCorrection = diff_match_patch.prototype.diff_prettyHtml(diffs)
		
		return prettyCorrection
	}
<p class="card-text">{{transformContentCorrection this.content}}</p>

You need triple tags: {{{transformContentCorrection this.content}}} - be aware of injection attacks if you allow users to provide that HTML.

2 Likes