I want to include a markdown file in my Smarty template.
In PHP I have this:
$smarty->assign('text', 'PATH_TO_FILE/text.md');
in the template I use:
{include file=$text}
but this returns an unformated block of text.
I tried using David Scherer’s markdown plugin for Smarty:
{markdown text=$text}
but this just returns the file path stored in the $text
variable.
How do I get Smarty to parse an included file as markdown?
You could instead read the file and assign the contents to the variable, then use the markdown plugin.
$smarty->assign('text', file_get_contents('PATH_TO_FILE/text.md'));
Manual page for file_get_contents()