-
Notifications
You must be signed in to change notification settings - Fork 888
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
about: add_static_view #3297
Comments
Could you paste an actual example? There's no reason you can't serve subfolders of templates as static assets... whether that's a good idea would be a separate discussion. |
of course. this is the tree..
init.py
views.py is untouched, just as it came in the cookiecutter..
and in layout.pt (that comes in cookiecutter i just added 4 images trying to use the static_views.
and the result is that i can see only the 3rd and 4th images, only those in templates directory cant be displayed. |
First, please review community guidelines for how to get support. You've posted to the smallest audience out of all others. Second, I've never tried putting template files and static assets in the same directory, but I assume that doing so would allow the templates to be served as a static asset. I don't do it because it's more configuration than necessary. Finally, you've got your
Read more in the narrative documentation about Static Assets. |
".. review community guidelines.."
R> sorry for being that person. from now on i will use stackO for this.
".. I've never tried putting template files and static assets in the same directory.."
R> neither i put in the same flat directory, i wanted to have the static assets used in templates in ../templates/static and create a static_view pointed to this, not to templates (originally that was the idea, i pointed it to templates only in the tests i sent you).
".. arguments swapped.."
R> this is the strange part. when i swap them the app crashes instead of just failing to render the images. and remember that two <img> tags work perfectly fine with my "swapped" definitions. ???
ok i tried this
config.add_static_view('in_templates2', 'templates/other')
and the app crashes when i call it like this in the template
<img src="${request.static_url('project:in_templates2/other/logo.bmp')}" alt="01"></img>
but it works when i call it like this..
<img src="${request.static_url('project:templates/other/logo.bmp')}" alt="01"></img>
being this way, the name is not used.
do you want me to close this ticket and open it in stackoverflow?
regards.
En Mon, 21 May 2018 01:19:40 -0500
, Steve Piercy <notifications@github.com> escribió:
First, please review community guidelines for how to get support. You've posted to the smallest audience out of all others.
https://pylonsproject.org/community-support.html
Second, I've never tried putting template files and static assets in the same directory, but I assume that doing so would allow the templates to be served as a static asset. I don't do it because it's more configuration than necessary.
Finally, you've got your pyramid.config.Configurator.add_static_view<https://docs.pylonsproject.org/projects/pyramid/en/latest/api/config.html#pyramid.config.Configurator.add_static_view> configuration arguments swapped. The name goes first, then the path, and finally any **kw.
config.add_static_view('in_templates2', 'templates/other')
Read more in the narrative documentation about Static Assets<https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/assets.html>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#3297 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AYsVUb2Xu_9cyFDDgDJp6VhSTRnU0YsAks5t0lx8gaJpZM4UGXBJ>.
…--
JG
|
You would get a larger audience on SO. I can't follow your issue or reproduce it with the information provided. If you go that route, include a MCVE, such as a link to a GitHub repo, and what steps you take to cause a crash. |
I think you should see that the generated URL is to The naming in |
Closing this as it seems you have something working... we can re-open if there's anything further but I would also suggest posting to SO first as @stevepiercy suggested so you can get a wider audience. |
How about fixing this by adding it to the list in issue #2362 ? |
You're welcome to add it but I'll warn you that Pyramid 2.0 is not going to break bw-compat lightly - something like naming of a var is unlikely to get fixed by just swapping the names. The best path forward here is to propose new names and migrate toward them with a deprecation strategy - or just live with it like people have for years :-) |
hi.
building a site i could not make use of the static views.
long story short: i started from zero using the starter cookiecutter and realized that the add_static_view does not work for subfolders of "../templates". for any other location works fine.
is this a bug?
is it supposed to work this way? if so, i suggest to include this advice in the docs.
regards
The text was updated successfully, but these errors were encountered: