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

Leaf template compiler issues #64

Closed
Sherlouk opened this issue Mar 1, 2022 · 5 comments
Closed

Leaf template compiler issues #64

Sherlouk opened this issue Mar 1, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@Sherlouk
Copy link

Sherlouk commented Mar 1, 2022

Describe the bug

If you create a new Vapor project with Leaf and no Fluent, then the project generates incorrectly.

To Reproduce

$ vapor new test-project
Cloning template...
name: test-project
Would you like to use Fluent?
y/n> n
fluent: No
Would you like to use Leaf?
y/n> y
leaf: Yes
Generating project files
...

routes.swift

import Vapor

func routes(_ app: Application) throws {
    app.get { req in
        return req.view.render("index", ["title": "Hello Vapor!"])
    }app.get { req in // this block shouldn't be here
        return "It works!"
    }

    app.get("hello") { req -> String in
        return "Hello, world!"
    }
}

configure.swift (no app.views.use(.leaf))

import Leaf
import Vapor

// configures your application
public func configure(_ app: Application) throws {
    // uncomment to serve files from /Public folder
    // app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))

    // register routes
    try routes(app)
}

Expected behavior

The project should compile after being generated, and should be setup correctly to use Leaf.

Environment

vapor: stable 18.3.3 (bottled), HEAD
xcode: 13.2.1 and 13.3 tested
macos: monterey 12.1

Additional context

has existed for quite a while, only just raising it

@Sherlouk Sherlouk added the bug Something isn't working label Mar 1, 2022
@Sherlouk
Copy link
Author

Sherlouk commented Mar 1, 2022

Package.swift

        .package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
        .package(url: "https://github.com/vapor/leaf.git", from: "4.0.0"),
    ],
    targets: [
        .target(
            name: "App",
            dependencies: [
                .product(name: "Vapor", package: "vapor"),
            ],

Leaf dependency is added but not to the target too.

@Sherlouk
Copy link
Author

Sherlouk commented Mar 1, 2022

It's very confusing because the syntax looks right for the scenarios where it does work and doesn't work.

My best guess is it seems to always manage the first tag, but not the subsequent ones? Like it'll do the import, but not the statement. It'll add the dependency but not to the target. Always the first one?

@Sherlouk
Copy link
Author

Sherlouk commented Mar 1, 2022

This issue probably belongs more in the toolkit repo, on reflection. I'm just seeing if I can reproduce the issue with a unit test over there :)

@Sherlouk
Copy link
Author

Sherlouk commented Mar 1, 2022

Very perplexing... my unit test is passing 🤔 Same exact template as what is failing here...

@Sherlouk
Copy link
Author

Sherlouk commented Mar 1, 2022

and that my friends is because this bug has been fixed in a more recent version of the toolbox. turns out when I thought I updated last week, it didn't.

sorry for the unnecessary prompt! all is good

@Sherlouk Sherlouk closed this as completed Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants