My controller is looking something like this.
Each of the methods called generate some HTML. The concatenated HTML variable gives the final render of the page
Is there a better way to generate my HTML to render coming from different functions:
$html = $renderer->render($clear_form);
$html .= $this->render_preview();
$config = \Drupal::config('amu_import_ldap.settings');
if (null != $config) {
$submits = $config->get('import_submits');
$html .= $this->render_ldap_imports($submits);
}
$build = [
'#markup' => Markup::create("
{$html}
"),
];
return $build;
.=operator, it is more memory efficient to put the parts into an array, like$html = []; $html[] = "...";and at the end concatenate it:$result = implode($html);\$\endgroup\$