5121 Posts in 1527 Topics by 1119 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 873 Views |
-
Different Renderer. Replace SSViewer with different template system

20 December 2010 at 3:50pm
Hello, there are many existing PHP renderers (ex mustache https://github.com/bobthecow/mustache.php or smarty) and I already use one.
I'm trying to integrate silverstripe into my system, but the problem is SSViewer is hardcoded into silverstripe.
What is the best way to replace it?
I would prefer silverstripe developers to extract an interface from SSViewer so that we can create an adapter to another view renderer and safely substitute SSViewer. And also create a factory class that would select correct renderer for each template.
-
Re: Different Renderer. Replace SSViewer with different template system

20 December 2010 at 6:31pm
There is an effort going on to replace SSViewer. I'm not sure if this will allow other engines to be plugged in but more details will be available once it's near release (https://groups.google.com/d/msg/silverstripe-dev/U-V9wHkr0pw/4VquyohkATAJ). I doubt an easy 'plug and play' system for templates is going to be possible as even with the new template engine things like data structures / orm based features are still very tightly coupled to framework and going to be quite hard to abstract.
Remember seeing someone hack smarty rendering into SS2.3 (try a search) but it wasn't a practical addition to the framework.
-
Re: Different Renderer. Replace SSViewer with different template system

21 December 2010 at 4:28am
For now I managed to post-process output and modify it before it is sent to the browser.
Also for now I managed to get it mostly working with my output renderers by including generated string into SSViewer output.One more question, is it possibile to include the output of the method call into SSViewer? i.e instead of $var to do $func()
class GemsPage_Controller extends Page_Controller {
private function gemsFilter($rawOutput) {
// perform search and replace here
}function handleRequest(SS_HTTPRequest $request) {
$this->pushCurrent();$response = parent::handleRequest($request);
$rawOutput = $response->getBody();
$translationFilter = new TranslationFilter();
$cssFileter = new CssFilter(true);
$jsFilter = new JsFilter(true);
$response->setBody($this->gemsFilter($rawOutput));$this->popCurrent();
return $response;
}public function handleAction($request) {
$result = parent::handleAction($request);
return $this->gemsFilter($result);
}
}
| 873 Views | ||
|
Page:
1
|
Go to Top |


