pug-php / pug

Pug template engine for PHP
https://www.phug-lang.com
MIT License
387 stars 42 forks source link

Tag Name error #244

Closed trentwiles closed 3 years ago

trentwiles commented 3 years ago

Hello,

I'm a bit new to pug in PHP and am getting this error:

[Tue Oct 27 17:51:53.614530 2020] [php7:error] [pid 841] [client x.x.x.x:0] PHP Fatal error:  Uncaught Phug\\ParserException: Failed to parse: The element already has a tag name
Near: .pug
Line: 1
Offset: 7

What does this mean? I have defined all of the variables in my pug file:

include head.pug
br
h1 Stats
p Interesting statistics about Riverside Rocks projects and creations.
br
h2 #{projects}
br
h2 #{bot_users}
kylekatarnls commented 3 years ago

Hello,

I ran this code without issue, so the problem is not in this pug file. Please provide the PHP code that parse it and head.pug

trentwiles commented 3 years ago
$pug = new Pug();
    $output = $pug->render('views/count.pug', array(
        'bot_users' => $stat[0],
        'bot_servers' => $stat[1],
        'bot_commands' => $stat[2],
        'requests' => $timev2
    ));
    echo $output;

I've checked and all these variables are defined.

kylekatarnls commented 3 years ago

You're not rendering the view/count.pug file here, render() take a Pug code string as input, so this will actually try to render as a Pug code the string "view/count.pug" and so it fails.

You need to use renderFile() instead.

Thanks.

trentwiles commented 3 years ago

Thanks, I'll have a look.

kylekatarnls commented 3 years ago

I see the README is not up to date, I will fix it and recommend to refer mainly to https://phug-lang.com (the complete documentation).