I have custom email. I have passed HTML inside variable as follows.
But the issue is it is printing HTML instead of table
public function getTable()
{
$data = $this->getRequest()->getPostValue();
// echo "<pre>";
// print_r($data);
// die();
$size = substr_count($data['product_id'],',') + 1;
$tot_arr = array();
$value = array();
$title = array();
$first_spt = explode(',', $data['optiontitle']);
$first_spt_val = explode(':', $data['optionvalue']);
// for ($i=0; $i < 2; $i++) {
// $tot_arr[$i]['title'] = explode('@@', $key);
// }
foreach ($first_spt as $key) {
$title[] = explode('@@', $key);
}
foreach ($first_spt_val as $key => $val) {
$searchForValue = ',';
if( strpos($val, $searchForValue) !== false ) {
$str_arr = preg_split ("/\,/", $val);
foreach ($str_arr as $str_arrkey) {
//echo $key;die;
$value[$key][] = explode('@@', $str_arrkey);
}
}else{
$value[] = explode('@@', $val);
}
}
$html = "<table>";
$new = array();
for ($i=0; $i < $size; $i++) {
$html .= "<tr>";
// $title[$i] = isset($title[$i]) ? $title[$i] : null;
foreach ($title[$i] as $col) {
$html .= "<th>" . $col . "</th>";
}
$html .= "</tr>";
$html .= "<tr>";
// echo "<pre>";
// print_r($value);
// die();
if ($this->contains_array($value[$i]) == 'true') {
foreach ($value[$i] as $key) {
$html .= "<tr>";
$new = array_slice($key, 1, -1);
foreach ($new as $col) {
$html .= "<td>" . $col . "</td>";
}
$html .= "</tr>";
}
}else{
$new = array_slice($value[$i], 1, -1);
foreach ($new as $col) {
$html .= "<td>" . $col . "</td>";
}
}
$html .= "</tr>";
//$value[$i]
}
$html .= "</table>";
// echo "<pre>";
// print_r($html);
// die();
return $html;
}
For call this in templateoptions variable I have addded
$optionTitle = $this->getTable();
Output is like
I need to print table & not table tags
My type is HTML in email_templates.xml
Template HTML I have added
<td colspan="2" valign="top" style="font-size:12px;padding:7px 9px 9px 9px;border:1px solid #EAEAEA;">
{{var optionTitle}}<br></n>
{{var optionValue}}
</td>