MDL-78282 output: new sr_text renderer method

Some output classes require pre-rendered elements. In some cases, those
elements require some screen reader extra texts (especially in buttons).
The st_text method allow the outputs to create those inline tags without
using html_writer. Furthermore, the current screen reader classes are
based on bootstrap, having them isolated in renderer methods allow
themes to implement alternatives accessibility HTML structures.
This commit is contained in:
Ferran Recio 2023-07-26 15:37:47 +02:00
parent 01e0e56665
commit a586e952ff
2 changed files with 15 additions and 0 deletions

View File

@ -3277,6 +3277,20 @@ EOD;
);
}
/**
* Outputs a screen reader only inline text.
*
* @param string $contents The contents of the paragraph
* @return string the HTML to output.
*/
public function sr_text(string $contents): string {
return html_writer::tag(
'span',
$contents,
['class' => 'sr-only']
) . ' ';
}
/**
* Outputs a container.
*

View File

@ -53,6 +53,7 @@ information provided here is intended especially for developers.
the page displays a heading for the activity (usually a h2 heading containing the activity name).
* New method moodleform::filter_shown_headers() is created to show some expanded headers only and hide the rest.
* count_words() and count_letters() have a new optional parameter called $format to format the text before doing the counting.
* New core_renderer::sr_text method to generate screen reader only inline texts without using html_writter.
=== 4.2 ===