Im trying to render a site macro from my plugin, i’m getting the following error:
Argument 1 passed to Twig_Template::display() must be of the type array, object given, called in /path/to/file.php on line 51 and defined in "_macros/elements" at line 3
My service contains the following method:
public function renderSiteMacro($template, $macro, array $args)
{
// Get the current template path
$originalPath = craft()->path->getTemplatesPath();
// Point Twig at the site templates
craft()->path->setTemplatesPath(craft()->path->getSiteTemplatesPath());
// Render the macro.
$html = craft()->templates->renderMacro($template, $macro, $args);
// Restore the original template path
craft()->path->setTemplatesPath($originalPath);
return TemplateHelper::getRaw($html);
}
And i'm calling it as follows:
$args = array(
'entry' => $user,
'layout' => 'friend'
);
$userHtml = craft()->logic->renderSiteMacro('_macros/elements', 'listing', $args);
The issue appears to be with the include line in my macro template file:
{% macro listing(config) %}
{% include "_macros/elements/listing" with config only %}
{% endmacro %}
Does anyone know what i'm missing?