Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't use League\Plates\Extension\Asset; #317

Open
adeilsonaalima opened this issue Jun 28, 2023 · 0 comments
Open

I can't use League\Plates\Extension\Asset; #317

adeilsonaalima opened this issue Jun 28, 2023 · 0 comments

Comments

@adeilsonaalima
Copy link

adeilsonaalima commented Jun 28, 2023

Sorry for my english... anyway:

This is my controller:

<?php

namespace src\controllers;

use League\Plates\Engine;
use League\Plates\Extension\Asset;

class Web
{
    private $templates;

    public function __construct()
    {
        $this->templates = new Engine(__DIR__ . "/../views", "php");
        $this->templates->loadExtension(new Asset(__DIR__ . '/../assets/', false)); // or true
    }

    public function home(): void
    {
        echo $this->templates->render("register-and-login/home", [
            "title" => "Home | " . SITE,
            "users" => ["Adeilson", "Karol"]
        ]);
    }
}

And this is in my template:

<link rel="stylesheet" href="<?= $this->asset('/css/style.css') ?>">

If I change to a non-existent path it gives an error 500, but if it is correct it defines the following path when rendering:

<link rel="stylesheet" href="/css/style.css?v=1687988335">

And this error:

GET https://mysite.com.br/css/style.css?v=1687988335 net::ERR_ABORTED 404 (Not Found)

Why? Someone can help me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant