SHARE
TWEET

Untitled

a guest Jun 16th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 %}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top