MDL-86541 blocks: validate allowing block title to be '0' (zero).

This commit is contained in:
Diego Monroy
2025-09-09 13:34:58 +02:00
parent 8e37adaddf
commit 4be66b0dfb
2 changed files with 20 additions and 5 deletions
+2 -1
View File
@@ -1495,7 +1495,8 @@ class core_renderer extends renderer_base {
$context->ariarole = !empty($bc->attributes['role']) ? $bc->attributes['role'] : '';
$context->class = $bc->attributes['class'];
$context->type = $bc->attributes['data-block'];
$context->title = $bc->title;
$context->title = (string) $bc->title;
$context->showtitle = $context->title !== '';
$context->content = $bc->content;
$context->annotation = $bc->annotation;
$context->footer = $bc->footer;
+18 -4
View File
@@ -1,3 +1,16 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/block
@@ -8,6 +21,7 @@
"showskiplink": true,
"type": "html",
"ariarole": "",
"showtitle": true,
"title": "Test block",
"blockinstanceid": 1,
"content": "<p>Hello block world!</p>"
@@ -29,18 +43,18 @@
aria-label="{{arialabel}}"
{{/arialabel}}
{{^arialabel}}
{{#title}}
{{#showtitle}}
aria-labelledby="instance-{{blockinstanceid}}-header"
{{/title}}
{{/showtitle}}
{{/arialabel}}>
{{! Block contents }}
<div class="card-body p-3">
{{! Block header }}
{{#title}}
{{#showtitle}}
<h3 id="instance-{{blockinstanceid}}-header" class="h5 card-title d-inline">{{{title}}}</h3>
{{/title}}
{{/showtitle}}
{{#hascontrols}}
<div class="block-controls float-end header">