Silverstrip template return value as string instead of html

Silverstrip template return value as string instead of html.

Please advice to return value as html.

Template call:
$decodeLinkData($CallToActionLink2)

public function decodeLinkData($linkJson)
{
if (!$linkJson || $linkJson === ‘null’) {
return;
}

    $data = json_decode(html_entity_decode($linkJson), true);
	
	if($data['PageID']){
		if($data['TargetBlank']){
			$target = 'target="_blank"';
		}else{
			$target = '';
		}
		$data =   '<a href="'.SiteTree::get()->byID($data['PageID'])->Link().'" '.$target.' class="banner-element__call-to-action">'.$data['Text'].'</a>';
		
	}
	return  $data;
}

SilverStripe does not know what kind of data you are returning, so by default it takes the safe way (i.e. it escapes the result). Instead of a raw string, you should return an object with explicit type (such as DBHTMLText) or use the casting feature:

    private static $casting = [
        'decodeLinkData' => 'HTMLText' 
    ];