PHP code example of lejahmie / slim-mustache-view

1. Go to this page and download the library: Download lejahmie/slim-mustache-view library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lejahmie / slim-mustache-view example snippets



 = new \Slim\Slim();
$container = $app->getContainer();
$container['view'] = function ($c) {
    $mustache = new \Slim\Mustache\Mustache(
        '/templates', // Template path
        array(
            'charset' => 'UTF-8',
        ),
        array(
            'extension' => '.html'
        )
    );
    return $mustache;
};
$app->get('/', function (Request $request, Response $response) {
    // The render method takes the reponse object,
    // template name and finally some data as an array.
    $response = $this->view->render($response, "hello", ["foo" => 'bar']);
    return $response;
});
render($templateName, $data)
$response->getBody()->write($output);
getRenderedMarkup($templateName, $data)
getRenderedMarkup($templateName, $data)