Merge branch 'MDL-50084-master' of git://github.com/gurgus/moodle

This commit is contained in:
Andrew Nicols
2015-05-05 10:18:21 +08:00
2 changed files with 21 additions and 8 deletions
+19 -1
View File
@@ -503,7 +503,7 @@ class help_icon implements renderable {
* @package core
* @category output
*/
class pix_icon implements renderable {
class pix_icon implements renderable, templatable {
/**
* @var string The icon name
@@ -545,6 +545,24 @@ class pix_icon implements renderable {
unset($this->attributes['title']);
}
}
/**
* Export this data so it can be used as the context for a mustache template.
*
* @param renderer_base $output Used to do a final render of any components that need to be rendered for export.
* @return array
*/
public function export_for_template(renderer_base $output) {
$attributes = $this->attributes;
$attributes['src'] = $output->pix_url($this->pix, $this->component);
$templatecontext = array();
foreach ($attributes as $name => $value) {
$templatecontext[] = array('name' => $name, 'value' => $value);
}
$data = array('attributes' => $templatecontext);
return $data;
}
}
/**
+2 -7
View File
@@ -2095,13 +2095,8 @@ class core_renderer extends renderer_base {
* @return string HTML fragment
*/
protected function render_pix_icon(pix_icon $icon) {
$attributes = $icon->attributes;
$attributes['src'] = $this->pix_url($icon->pix, $icon->component);
$templatecontext = array();
foreach ($attributes as $name => $value) {
$templatecontext[] = array('name' => $name, 'value' => $value);
}
return $this->render_from_template('core/pix_icon', array('attributes' => $templatecontext));
$data = $icon->export_for_template($this);
return $this->render_from_template('core/pix_icon', $data);
}
/**