Skip to content
Permalink
Browse files

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.
  • Loading branch information...
damyon committed Jun 27, 2017
1 parent 7624f86 commit 4197baf775224870a883fa52b6c64728656d831f
Showing with 7 additions and 7 deletions.
  1. +6 −6 lib/classes/output/mustache_javascript_helper.php
  2. +1 −1 lib/outputrenderers.php
@@ -34,16 +34,16 @@
*/
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 @@ public function __construct($requires) {
* @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 @@ protected function get_mustache() {
$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.

0 comments on commit 4197baf

Please sign in to comment.
You can’t perform that action at this time.