openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

commit eb310155f028ae9817d29b0ca68f4861b9b7e115
parent 233fbe1b15a51c8920baeef34e993c0d4aea009f
Author: Jan Dankert <develop@jandankert.de>
Date:   Mon, 11 Nov 2019 23:10:03 +0100

New: Support for template-partials. This is part of the mustache spec.

Diffstat:
modules/cms-core/model/Page.class.php | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/modules/cms-core/model/Page.class.php b/modules/cms-core/model/Page.class.php @@ -18,6 +18,7 @@ namespace cms\model; // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. use cms\mustache\Mustache; use cms\publish\PublishPreview;use cms\publish\PublishPublic; +use http\Exception\RuntimeException; use Logger; use util\FileCache; @@ -630,6 +631,18 @@ SQL $template = new Mustache(); $template->escape = null; // No HTML escaping, this is the job of this CMS ;) + $template->partialLoader = function( $name ) { + if ( $name == $this->template->name ) + throw new RuntimeException('Template recursion is not possible.'); + + $project = new Project($this->projectid); + $templateid = array_search($name,$project->getTemplates() ); + $templatemodel = new TemplateModel( $templateid, $this->modelid ); + $templatemodel->load(); + + return $templatemodel->src; + }; + try { $template->parse($src); } catch (\Exception $e) {