MDL-59380 fragments: Include js from templates
Mustache templates containing {{#js}} blocks are not returned via the
fragments API. This is because the requirements manager is assigned when the renderer is created
and not updated by the call to start collecting page requirements.
This commit is contained in:
@@ -34,16 +34,16 @@ namespace core\output;
|
||||
*/
|
||||
class mustache_javascript_helper {
|
||||
|
||||
/** @var page_requirements_manager $requires - Page requirements manager for collecting JS calls. */
|
||||
private $requires = null;
|
||||
/** @var moodle_page $page - Page used to get requirement manager */
|
||||
private $page = null;
|
||||
|
||||
/**
|
||||
* Create new instance of mustache javascript helper.
|
||||
*
|
||||
* @param page_requirements_manager $requires Page requirements manager.
|
||||
* @param moodle_page $page Page.
|
||||
*/
|
||||
public function __construct($requires) {
|
||||
$this->requires = $requires;
|
||||
public function __construct($page) {
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,6 +54,6 @@ class mustache_javascript_helper {
|
||||
* @param \Mustache_LambdaHelper $helper Used to render the content of this block.
|
||||
*/
|
||||
public function help($text, \Mustache_LambdaHelper $helper) {
|
||||
$this->requires->js_amd_inline($helper->render($text));
|
||||
$this->page->requires->js_amd_inline($helper->render($text));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class renderer_base {
|
||||
$loader = new \core\output\mustache_filesystem_loader();
|
||||
$stringhelper = new \core\output\mustache_string_helper();
|
||||
$quotehelper = new \core\output\mustache_quote_helper();
|
||||
$jshelper = new \core\output\mustache_javascript_helper($this->page->requires);
|
||||
$jshelper = new \core\output\mustache_javascript_helper($this->page);
|
||||
$pixhelper = new \core\output\mustache_pix_helper($this);
|
||||
|
||||
// We only expose the variables that are exposed to JS templates.
|
||||
|
||||
Reference in New Issue
Block a user