Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. require_once(__DIR__ . '/vendor/autoload.php');
  2.  
  3. class Test {
  4.  
  5. public $loader;
  6. public $twig;
  7.  
  8. public function __construct() {
  9. $this->loader = new Twig_Loader_Filesystem(__DIR, . '/templates');
  10.  
  11. $this->twig = new Twig_Environment($this->loader);
  12.  
  13. $this->show_page();
  14. }
  15.  
  16. public function show_page() {
  17. $results = get_results_from_db();
  18.  
  19. $template = $this->twig->loadTemplate('results.twig');
  20.  
  21. $template->render([
  22. 'results' => $results,
  23. ]);
  24. }
  25. }
  26.  
  27. {% for result in results %}
  28. <p>{{ result.name }}</p>
  29. {% endfor %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement