Guest User

Untitled

a guest
Dec 14th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <?php
  2.  
  3. // Install Pug with: composer require pug-php/pug
  4.  
  5. $app['view'] = function () {
  6. return new Pug(array(
  7. 'cache' => './storage/cache',
  8. 'paths' => array(
  9. // Here you can record differents root directories
  10. // containing pug templates.
  11. './views',
  12. ),
  13. ));
  14. };
  15.  
  16. $app->get('/hello/{name}', function ($name) use ($app) {
  17. // Supposing you have a template stored in ./views/hello.pug
  18. return $app['view']->renderFile('hello', array(
  19. 'name' => $name,
  20. ));
  21. });
  22.  
  23. // You can call the service more explicitly $app['pug'] and call explicitly
  24. // templates files with extensions ->renderFile('hello.pug')
  25. // but the benefit of the "view" naming and extension omit is it allow you
  26. // to easily switch to an other template engine.
Add Comment
Please, Sign In to add comment