Custom Moodle helper collection for mustache.
More...
|
| __construct ($helpers=null, array $disallowednestedhelpers=[]) |
| Helper Collection constructor.
|
|
| __get ($name) |
| Magic accessor.
|
|
| __isset ($name) |
| Magic isset().
|
|
| __set ($name, $helper) |
| Magic mutator.
|
|
| __unset ($name) |
| Magic unset().
|
|
| add ($name, $helper) |
| Add a helper to this collection.
|
|
| clear () |
| Clear the helper collection.
|
|
| get ($name) |
| Get a helper by name.
|
|
| has ($name) |
| Check whether a given helper is present in the collection.
|
|
| isEmpty () |
| Check whether the helper collection is empty.
|
|
| remove ($name) |
| Check whether a given helper is present in the collection.
|
|
| strip_blacklisted_helpers () |
|
| strip_disallowed_helpers ($disallowedlist, $string) |
| Parse the given string and remove any reference to disallowed helpers.
|
|
Custom Moodle helper collection for mustache.
- Copyright
- 2019 Ryan Wyllie ryan@.nosp@m.mood.nosp@m.le.co.nosp@m.m
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ __construct()
core\output\mustache_helper_collection::__construct |
( |
| $helpers = null, |
|
|
array | $disallowednestedhelpers = [] ) |
Helper Collection constructor.
Optionally accepts an array (or Traversable) of $name => $helper
pairs.
- Exceptions
-
- Parameters
-
array | Traversable | $helpers | (default: null) |
string[] | $disallowednestedhelpers | Names of helpers that aren't allowed to be called within other helpers. |
◆ __get()
Mustache_HelperCollection::__get |
( |
| $name | ) |
|
|
inherited |
◆ __isset()
Mustache_HelperCollection::__isset |
( |
| $name | ) |
|
|
inherited |
◆ __set()
Mustache_HelperCollection::__set |
( |
| $name, |
|
|
| $helper ) |
|
inherited |
◆ __unset()
Mustache_HelperCollection::__unset |
( |
| $name | ) |
|
|
inherited |
◆ add()
core\output\mustache_helper_collection::add |
( |
| $name, |
|
|
| $helper ) |
Add a helper to this collection.
This function has overridden the parent implementation to provide disallowing functionality for certain helpers to prevent them being called from within other helpers. This is because the JavaScript helper can be used in a security exploit if it can be nested.
The function will wrap callable helpers in an anonymous function that strips out the disallowed helpers from the source string before giving it to the helper function. This prevents the disallowed helper functions from being called by nested render functions from within other helpers.
- See also
- Mustache_HelperCollection\add()
- Parameters
-
Reimplemented from Mustache_HelperCollection.
◆ clear()
Mustache_HelperCollection::clear |
( |
| ) |
|
|
inherited |
Clear the helper collection.
Removes all helpers from this collection
◆ get()
Mustache_HelperCollection::get |
( |
| $name | ) |
|
|
inherited |
Get a helper by name.
- Exceptions
-
- Parameters
-
- Return values
-
◆ has()
Mustache_HelperCollection::has |
( |
| $name | ) |
|
|
inherited |
Check whether a given helper is present in the collection.
- Parameters
-
- Return values
-
bool | True if helper is present |
◆ isEmpty()
Mustache_HelperCollection::isEmpty |
( |
| ) |
|
|
inherited |
Check whether the helper collection is empty.
- Return values
-
bool | True if the collection is empty |
◆ remove()
Mustache_HelperCollection::remove |
( |
| $name | ) |
|
|
inherited |
Check whether a given helper is present in the collection.
- Exceptions
-
- Parameters
-
◆ strip_blacklisted_helpers()
core\output\mustache_helper_collection::strip_blacklisted_helpers |
( |
| ) |
|
◆ strip_disallowed_helpers()
core\output\mustache_helper_collection::strip_disallowed_helpers |
( |
| $disallowedlist, |
|
|
| $string ) |
Parse the given string and remove any reference to disallowed helpers.
E.g. $disallowedlist = ['js']; $string = "core, move, {{#js}} some nasty JS hack {{/js}}" result: "core, move, {{}}"
- Parameters
-
string[] | $disallowedlist | List of helper names to strip |
string | $string | String to parse |
- Return values
-
The documentation for this class was generated from the following file:
- lib/classes/output/mustache_helper_collection.php