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
tplimpl: Allow text partials in HTML templates #3347
Conversation
I have put #3273 into a 0.20.2 milestone. I notice some breaking themes that include partials on the form "mystyles.css", which does not work without also allowing fetching text templates into html and the other way around. I think we should just put this out there before people start to make clever workarounds. This will make the inline CSS story so much better. I will do some more manual testing and thinking about this, but please comment. And note: This is relevant for partials only. |
3fed467
to
b15e145
Compare
Just tested this with my site. So:
Which I would say is expected and good behaviour and I have added tests for it. I think I will figure a way for the plain text partial variant to return |
afcae00
to
05591bd
Compare
I'm talking to myself here, but now I'm happy with the implementation. Text partials will return a |
Most obvius benefit of this is to include CSS partials with css file suffix into HTML templates. A valid workaround would be to rename the file `mystyles.html`, but that doesn't work too good for external editors etc. The css partial is a method used in some themes before Hugo 0.20, but then it stopped working. This commit reintroduces that behaviour. Note that the regular layout lookups for text templates, i.e. "single.json" will be prefixed with "_text/" on lookup and will only match in the text collection. Fixes gohugoio#3273
This is a great addition and easier than the hack-ish approach I was taking to CRP with printf. If nothing else, I think long-time Hugo users are used to leveraging safeJS, safeHTML, and safeCSS as a matter of habit with Golang templates. Thanks for this added feature and convenience @bep. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Most obvius benefit of this is to include CSS partials with css file suffix into HTML templates.
A valid workaround would be to rename the file
mystyles.html
, but that doesn't work too good for external editors etc.The css partial is a method used in some themes before Hugo 0.20, but then it stopped working.
This commit reintroduces that behaviour.
Note that the regular layout lookups for text templates, i.e. "single.json" will be
prefixed with "_text/" on lookup and will only match in the text collection.
Fixes #3273