Your Location is: Home > Php

Pug isn't outputing my variables on the template side

From: Denmark View: 1893 x43 


I'm using Pug in PHP. Right now I am using it with a simple PHP router. I have a server side file index.php and a templating file index.pug. I am passing the times constant to the template.

Here is my code

$router->get('/', function() {
    $pug = new Pug();
    $output = $pug->render('views/index.pug', array(
        'title' => times
    echo $output;

This is the code I have on my template:

p #{visits}

When I run the program and render the template, I get this output:


I checked by logs and I have nothing. For a test, I echoed the output on another page like so...

$router->get('/api/visits', function() {
    echo times;

..and the correct output of 1716 is returned. Any idea what I am doing wrong?

Best answer