-
Notifications
You must be signed in to change notification settings - Fork 24
New application with buffalo 0.18: could not find templates errors #55
Comments
The first issue you are reporting is probably caused by a missing //go:embed * _flash.plush.html
var files embed.FS with //go:embed * _flash.plush.html
//go:embed myres/*
var files embed.FS in your |
@paganotoni can you transfer this issue to the buffalo/cli repo? |
Thank you @fasmat for your quick answer ! I realised that I had GO111MODULE set to auto, I updated my env variable to I did the I still have the first problem:
which requires me to remove the leading flash with Then I can confirm that the |
@lsorba: no problem
Regarding the leading slash: this is an issue in the resource generator that was overlooked in the upgrade between 0.17.x and 0.18.0. I will try to fix it, as soon as I get to it. |
I also stumbled on this but in a slight different way.
diff --git a/actions/messages.go b/actions/messages.go
index 8c3c4b9..8c764ff 100644
--- a/actions/messages.go
+++ b/actions/messages.go
@@ -52,7 +52,7 @@ func (v MessagesResource) List(c buffalo.Context) error {
c.Set("pagination", q.Paginator)
c.Set("messages", messages)
- return c.Render(http.StatusOK, r.HTML("/messages/index.plush.html"))
+ return c.Render(http.StatusOK, r.HTML("messages/index.plush.html"))
}).Wants("json", func (c buffalo.Context) error {
return c.Render(200, r.JSON(messages))
}).Wants("xml", func (c buffalo.Context) error {
@@ -80,7 +80,7 @@ func (v MessagesResource) Show(c buffalo.Context) error {
return responder.Wants("html", func (c buffalo.Context) error {
c.Set("message", message)
- return c.Render(http.StatusOK, r.HTML("/messages/show.plush.html"))
+ return c.Render(http.StatusOK, r.HTML("messages/show.plush.html"))
}).Wants("json", func (c buffalo.Context) error {
return c.Render(200, r.JSON(message))
}).Wants("xml", func (c buffalo.Context) error {
@@ -93,7 +93,7 @@ func (v MessagesResource) Show(c buffalo.Context) error {
func (v MessagesResource) New(c buffalo.Context) error {
c.Set("message", &models.Message{})
- return c.Render(http.StatusOK, r.HTML("/messages/new.plush.html"))
+ return c.Render(http.StatusOK, r.HTML("messages/new.plush.html"))
}
// Create adds a Message to the DB. This function is mapped to the
// path POST /messages
@@ -127,7 +127,7 @@ func (v MessagesResource) Create(c buffalo.Context) error {
// correct the input.
c.Set("message", message)
- return c.Render(http.StatusUnprocessableEntity, r.HTML("/messages/new.plush.html"))
+ return c.Render(http.StatusUnprocessableEntity, r.HTML("messages/new.plush.html"))
}).Wants("json", func (c buffalo.Context) error {
return c.Render(http.StatusUnprocessableEntity, r.JSON(verrs))
}).Wants("xml", func (c buffalo.Context) error {
@@ -165,7 +165,7 @@ func (v MessagesResource) Edit(c buffalo.Context) error {
}
c.Set("message", message)
- return c.Render(http.StatusOK, r.HTML("/messages/edit.plush.html"))
+ return c.Render(http.StatusOK, r.HTML("messages/edit.plush.html"))
}
// Update changes a Message in the DB. This function is mapped to
// the path PUT /messages/{message_id}
@@ -202,7 +202,7 @@ func (v MessagesResource) Update(c buffalo.Context) error {
// correct the input.
c.Set("message", message)
- return c.Render(http.StatusUnprocessableEntity, r.HTML("/messages/edit.plush.html"))
+ return c.Render(http.StatusUnprocessableEntity, r.HTML("messages/edit.plush.html"))
}).Wants("json", func (c buffalo.Context) error {
return c.Render(http.StatusUnprocessableEntity, r.JSON(verrs))
}).Wants("xml", func (c buffalo.Context) error {
diff --git a/templates/embed.go b/templates/embed.go
index c5f0fca..bda6d0e 100644
--- a/templates/embed.go
+++ b/templates/embed.go
@@ -6,6 +6,7 @@ import (
)
//go:embed * _flash.plush.html
+//go:embed messages/*
var files embed.FS
func FS() fs.FS { |
Requested two PRs to fix this issue. One for template searching issue, another for leading slash issue. |
@sio4 thanks for taking over fixing this issue. @paganotoni with the two PRs this issue should be fixed. |
Hello! Thank you so much for this amazing work.
I am new in the go community, and attempting to get into it through gobuffalo.
I managed to make a basic app with the version 0.17, I updated buffalo yesterday and created a new app and I have wome troubles.
Sorry in advance if it is due to my little experience in go.
Description
I am getting few templating errors while running the application, I attempted to fix one but I am getting others.
Steps to Reproduce the Problem
I am creating an application from scratch using the buffalo new command :
buffalo new app --skip-yarn
buffalo generate resource myres field
buffalo pop create -a
buffalo pop migrate -d
buffalo dev
I am getting :go get app/actions
, I alternatively triedgo mod tidy
http://127.0.0.1:3000/myres/
=> HTTP 500sed -i 's/r\.HTML("\//r\.HTML("/' actions/*
http://127.0.0.1:3000/myres/
=> HTTP 200http://127.0.0.1:3000/myres/new/
=> HTTP 500cat templates/myres/new.plush.html
Expected Behavior
My expected behavior is that it is working out of the box (like my first attempts with buffalo 0.17) and also that the dependencies are resolved (if that is the problem).
Info
Please run
buffalo info
and paste the information below where it says "PASTE_HERE".Thank you in advance!
The text was updated successfully, but these errors were encountered: