Table does not parse blade variable as markdown
SalihBorucu opened this issue · comments
Describe the bug
If I generate the table markdown within using a variable, the table is only just printed as string and not as a table.
To Reproduce
Steps to reproduce the behavior:
Blade::directive('ticketTypes', function() {
$ticketTypes = TicketType::get();
$table = '';
foreach($ticketTypes as $ticketType) {
$table .= $ticketType->name . ' | ' . $ticketType->hash_id . ' | ' . '$'.$ticketType->getReadablePrice() . '<br>';
}
return $table;
});
1- Using blade directive generate a table markdown
2- Then use the blade directive within the markdown
Name | ID | Description
:- | : | :- |
@ticketTypes
Expected behavior
Table to be printed as a table not as string
Additional context
Is there a different way to do this?
I just need to form my table from the database
Thanks
I guess if anybody else does hit this point I managed to go around it by using direct html inside the markdown and generate the html elements within the variable:
<table>
<thead>
<tr>
<th>Name</th>
<th>ID</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
@ticketTypes
</tr>
</tbody>
</table>
foreach ($ticketTypes as $ticketType) {
$table .= <<<EOT
<tr>
<td>
$ticketType->name
</td>
<td>
$ticketType->hash_id
</td>
<td>
$ticketTypePrice
</td>
</tr>
EOT;
}