mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
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:
parent
0ad8fd077c
commit
0eaaf40f10
3 changed files with 18 additions and 1 deletions
|
@ -50,7 +50,7 @@ echo $OUTPUT->header();
|
|||
echo $OUTPUT->render_participants_tertiary_nav($course);
|
||||
echo $OUTPUT->heading(get_string('rolerenaming'));
|
||||
|
||||
echo $OUTPUT->container(get_string('rolerenaming_help'));
|
||||
echo $OUTPUT->paragraph(get_string('rolerenaming_help'));
|
||||
|
||||
$customdata = [
|
||||
'id' => $course->id,
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -7,6 +7,7 @@ information provided here is intended especially for developers.
|
|||
- admin_setting_requiredpasswordunmask
|
||||
* The badges_get_oauth2_service_options() method has been deprecated, because it's not required anymore. It should no longer
|
||||
be used.
|
||||
* New core_renderer::paragraph method to replace the overused html_writer::tag('p', ...) pattern.
|
||||
|
||||
=== 4.2 ===
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue