Skip to content

Commit

Permalink
Modify a mustache template from Moodle core
Browse files Browse the repository at this point in the history
  • Loading branch information
abias committed Feb 23, 2024
1 parent 36fc35a commit 56fcd9d
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 11 deletions.
72 changes: 72 additions & 0 deletions templates/core/block.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{{!
@template core/block
Example context (json):
{
"id": "block0",
"class": "block block_html",
"showskiplink": true,
"type": "html",
"ariarole": "complementary",
"title": "Test block",
"blockinstanceid": 1,
"content": "<p>Hello block world!</p>"
}

}}
{{!
This template is a modified version of core/block
Modifications compared to the original template:
* Moved the block controls into the block footer.
}}
{{! Block Skip Link }}
{{#showskiplink}}
<a href="#sb-{{skipid}}" class="sr-only sr-only-focusable">{{#str}}skipa, access, {{{title}}}{{/str}}</a>
{{/showskiplink}}

{{! Start Block Container }}
<section id="{{id}}"
class="{{#hidden}}hidden{{/hidden}} {{class}} {{#hascontrols}}block_with_controls{{/hascontrols}} card mb-3"
role="{{ariarole}}"
data-block="{{type}}"
data-instance-id="{{blockinstanceid}}"
{{#arialabel}}
aria-label="{{arialabel}}"
{{/arialabel}}
{{^arialabel}}
{{#title}}
aria-labelledby="instance-{{blockinstanceid}}-header"
{{/title}}
{{/arialabel}}>

{{! Block contents }}
<div class="card-body p-3">

{{! Block header }}
{{#title}}
<h5 id="instance-{{blockinstanceid}}-header" class="card-title d-inline">{{{title}}}</h5>
{{/title}}

<div class="card-text content mt-3">
{{{content}}}
<div class="footer">
{{{footer}}}
{{#hascontrols}}
<div class="block-controls pt-3 mt-3 border-top">
{{{controls}}}
</div>
{{/hascontrols}}
</div>
{{{annotation}}}
</div>

</div>

{{! End Block Container }}
</section>

{{! Block Skip Link Target }}
{{#showskiplink}}
<span id="sb-{{skipid}}"></span>
{{/showskiplink}}
16 changes: 5 additions & 11 deletions tests/behat/theme_boost_union_child.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ Feature: Extending the theme_boost_union plugin with a child theme
As developer
I need to be able to build several kinds of extensions to Boost Union

Scenario: Skeleton scenario
# This Behat scenario is just a skeleton which is ready for extension.
# Grunt in Github actions would not be happy with a feature file without any scenario.
# Thus, we log in as admin to keep it happy.
Scenario: Modify block.mustache template
When I log in as "admin"

#################################################################
# EXTENSION POINT:
# Add your Behat scenarios here.
# They will be tested alongside Boost Union's
# scenarios in Github Actions.
#################################################################
And I turn editing mode on
And I add the "Admin bookmarks" block
Then ".block_admin_bookmarks .footer .block-controls" "css_element" should exist
And ".block_admin_bookmarks .card-body > .block-controls" "css_element" should not exist

0 comments on commit 56fcd9d

Please sign in to comment.