From e501186d01d621b956aa442f7597bd9ed043dc34 Mon Sep 17 00:00:00 2001 From: Jack Phoenix Date: Thu, 21 Nov 2013 09:47:39 +0200 Subject: [PATCH] New getHTML() method for QuickTemplate to get the HTML of a template. OutputPage's addTemplate() is now a wrapper around QuickTemplate. This allows more flexible usage of templated HTML, as required by some third-party extensions. Change-Id: I943e8e50438c716b7b56d2f908da38a4bf73d9e2 --- includes/OutputPage.php | 5 +---- includes/SkinTemplate.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 5ffb80208a..638887b2aa 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1629,10 +1629,7 @@ class OutputPage extends ContextSource { * @param $template QuickTemplate */ public function addTemplate( &$template ) { - ob_start(); - $template->execute(); - $this->addHTML( ob_get_contents() ); - ob_end_clean(); + $this->addHTML( $template->getHTML() ); } /** diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 014d5142d7..2808cf9291 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -1457,6 +1457,20 @@ abstract class QuickTemplate { public function getSkin() { return $this->data['skin']; } + + /** + * Fetch the output of a QuickTemplate and return it + * + * @since 1.23 + * @return String + */ + public function getHTML() { + ob_start(); + $this->execute(); + $html = ob_get_contents(); + ob_end_clean(); + return $html; + } } /** -- 2.20.1