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

How to properly render a template? #34

Closed
rizafahmi opened this issue May 23, 2014 · 10 comments
Closed

How to properly render a template? #34

rizafahmi opened this issue May 23, 2014 · 10 comments

Comments

@rizafahmi
Copy link

How to properly render a template? I want to render index.html.eex by using render. In the docs says render conn, "showing index controller". I did that but not working. I did render conn, "main/index", render conn, "main/index.html" and render conn, "main/index.html.eex" but all ended up error File.Error: could not read file lib/views/main/index. Am I missing something?

@slogsdon
Copy link
Member

Sorry for the outdated docs. I'm working on getting those up to speed shortly.

render conn, "main/index.html.eex is what you want, but at the moment, there is an issue with the location of where Sugar looks for view files. There is a fix in the works, but it hasn't been pushed to master. For the time being, please move your views folder from lib/your_app/views to lib/views.

That should get you going until a proper fix can be introduced. Let me know if you run into any problems with this.

@slogsdon
Copy link
Member

@rizafahmi Were you able to get things working?

@rizafahmi
Copy link
Author

Nope. Still got an error: File.Error: could not read file lib/views/lib/sugar_pouchdb/views/main/index.html.eex: no such file or directory -> render conn, "lib/sugar_pouchdb/views/main/index.html.eex" or File.Error: could not read file lib/views/lib/sugar_pouchdb/views/index.html.eex: no such file or directory -> render conn, "lib/sugar_pouchdb/views/index.html.eex" as you suggested.

@slogsdon
Copy link
Member

The calls to render should not contain the directory structure, which is why render conn, "lib/sugar_pouchdb/views/main/index.html.eex" throws the error File.Error: could not read file lib/views/lib/sugar_pouchdb/views/main/index.html.eex. It is looking for your views in a directory that doesn't exist.

In your calls to render, lib/sugar_pouchdb/views/main/index.html.eex should become main/index.html.eex, and lib/sugar_pouchdb/views/index.html.eex should become index.html.eex.

@vjustov
Copy link
Contributor

vjustov commented Dec 10, 2014

I'm gonna take a go at this later tonight if thats ok with you.

@slogsdon
Copy link
Member

@vjustov Have at it if you have the time! 👍

@vjustov
Copy link
Contributor

vjustov commented Dec 13, 2014

Hey! @slogsdon, i have started working on this and have a couple small questions i'd like to ask. What do you think of opening a gitter.im room where everyone can talk about the project?

@vjustov
Copy link
Contributor

vjustov commented Dec 13, 2014

Im working on it at #49. feel free to give any insight.

@slogsdon
Copy link
Member

@vjustov I'd be open to opening a gitter.im room. In fact, consider it done. Looking into your PR now.

@slogsdon
Copy link
Member

#49 should make this loads easier thanks to @vjustov. Closing this as the issue should now be resolved.

Track documentation changes in #31.

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

No branches or pull requests

3 participants