MDL-78175 output: new paragraph renderer method

Many main php files still uses html_writer('p...) to render a simple
paragraphs below or under other elements like forms. In many cases those
texts could be part of a template but there are may scenarios were
creating a full template for a simple paragraph is too much. However,
the html_writer is too limiting as plugins cannot provide their own
implementation. This new method in the renderer is a good in between
solution.
This commit is contained in:
Ferran Recio
2023-05-29 09:26:04 +02:00
parent 0ad8fd077c
commit 0eaaf40f10
3 changed files with 18 additions and 1 deletions
+16
View File
@@ -3263,6 +3263,22 @@ EOD;
return $this->opencontainers->pop('box');
}
/**
* Outputs a paragraph.
*
* @param string $contents The contents of the paragraph
* @param string|null $classes A space-separated list of CSS classes
* @param string|null $id An optional ID
* @return string the HTML to output.
*/
public function paragraph(string $contents, ?string $classes = null, ?string $id = null): string {
return html_writer::tag(
'p',
$contents,
['id' => $id, 'class' => renderer_base::prepare_classes($classes)]
);
}
/**
* Outputs a container.
*