Load template source strings.
More...
|
| __construct (callable $gettemplatesource=null) |
| Constructor that takes a callback to allow the calling code to specify how to retrieve the source for a template name.
|
|
| load (string $component, string $name, string $themename, bool $includecomments=false) |
| Load the template source from the component and template name.
|
|
| load_with_dependencies (string $templatecomponent, string $templatename, string $themename, bool $includecomments=false, array $seentemplates=[], array $seenstrings=[], string $lang=null) |
| Load a template and some of the dependencies that will be needed in order to render the template.
|
|
Load template source strings.
- Copyright
- 2018 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_template_source_loader::__construct |
( |
callable | $gettemplatesource = null | ) |
|
Constructor that takes a callback to allow the calling code to specify how to retrieve the source for a template name.
If no callback is provided then default to the load from disk implementation.
- Parameters
-
callable | null | $gettemplatesource | Callback to load template source by template name |
◆ get_string_identifiers()
core\output\mustache_template_source_loader::get_string_identifiers |
( |
array | $tokens, |
|
|
int | $start ) |
|
protected |
Gets the identifier and component of the string.
The string could be defined on one, or multiple lines.
- Parameters
-
array | $tokens | The templates token. |
int | $start | The index of the start of the string token. |
- Return values
-
array | A list of the string identifier and component. |
◆ load()
core\output\mustache_template_source_loader::load |
( |
string | $component, |
|
|
string | $name, |
|
|
string | $themename, |
|
|
bool | $includecomments = false ) |
Load the template source from the component and template name.
- Parameters
-
string | $component | The moodle component (e.g. core_message) |
string | $name | The template name (e.g. message_drawer) |
string | $themename | The theme to load the template for (e.g. boost) |
bool | $includecomments | If the comments should be stripped from the source before returning |
- Return values
-
string | The template source |
◆ load_with_dependencies()
core\output\mustache_template_source_loader::load_with_dependencies |
( |
string | $templatecomponent, |
|
|
string | $templatename, |
|
|
string | $themename, |
|
|
bool | $includecomments = false, |
|
|
array | $seentemplates = [], |
|
|
array | $seenstrings = [], |
|
|
string | $lang = null ) |
Load a template and some of the dependencies that will be needed in order to render the template.
The current implementation will return all of the templates and all of the strings in each of those templates (excluding string substitutions).
The return format is an array indexed with the dependency type (e.g. templates / strings) then the component (e.g. core_message), and then the id (e.g. message_drawer).
For example:
- We have 3 templates in core named foo, bar, and baz.
- foo includes bar and bar includes baz.
- foo uses the string 'home' from core
- baz uses the string 'help' from core
If we load the template foo this function would return: [ 'templates' => [ 'core' => [ 'foo' => '... template source ...', 'bar' => '... template source ...', 'baz' => '... template source ...', ] ], 'strings' => [ 'core' => [ 'home' => 'Home', 'help' => 'Help' ] ] ]
- Parameters
-
string | $templatecomponent | The moodle component (e.g. core_message) |
string | $templatename | The template name (e.g. message_drawer) |
string | $themename | The theme to load the template for (e.g. boost) |
bool | $includecomments | If the comments should be stripped from the source before returning |
array | $seentemplates | List of templates already processed / to be skipped. |
array | $seenstrings | List of strings already processed / to be skipped. |
string | null | $lang | moodle translation language, null means use current. |
- Return values
-
◆ scan_template_source_for_dependencies()
core\output\mustache_template_source_loader::scan_template_source_for_dependencies |
( |
string | $source | ) |
|
|
protected |
Scan over a template source string and return a list of dependencies it requires.
At the moment the list will only include other templates and strings.
The return format is an array indexed with the dependency type (e.g. templates / strings) then the component (e.g. core_message) with it's value being an array of the items required in that component.
For example: If we have a template foo that includes 2 templates, bar and baz, and also 2 strings 'home' and 'help' from the core component then the return value would look like:
[ 'templates' => [ 'core' => ['foo', 'bar', 'baz'] ], 'strings' => [ 'core' => ['home', 'help'] ] ]
- Parameters
-
string | $source | The template source |
- Return values
-
◆ strip_template_comments()
core\output\mustache_template_source_loader::strip_template_comments |
( |
| $templatestr | ) |
|
|
protected |
Remove comments from mustache template.
- Parameters
-
- Return values
-
The documentation for this class was generated from the following file:
- lib/classes/output/mustache_template_source_loader.php