Created
October 20, 2016 17:45
-
-
Save bwaidelich/de03b02567da16c35bb6203cd48948b5 to your computer and use it in GitHub Desktop.
Very simple Template View for Neos Flow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Some\Package\View; | |
use TYPO3\Flow\Mvc\View\AbstractView; | |
use TYPO3\Flow\Reflection\ObjectAccess; | |
class SimpleTemplateView extends AbstractView | |
{ | |
/** | |
* @var array | |
*/ | |
protected $supportedOptions = [ | |
'templateSource' => [null, 'Source of the template to render', 'string', true], | |
]; | |
/** | |
* Renders the view | |
* | |
* @return string The rendered view | |
* @api | |
*/ | |
public function render() | |
{ | |
$source = $this->getOption('templateSource'); | |
return preg_replace_callback('/\{([a-zA-Z0-9\-_.]+)\}/', function($matches) { | |
return ObjectAccess::getPropertyPath($this->variables, $matches[1]); | |
}, $source); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: