Closed EmpireJones closed 9 months ago
Had a "fight" with this problem in the last two days.
Want to use SVG sprites references in the page, saving the needed sprites in a scratch map, to include the sprite at the end of the page. Must set scratch deep in called partials and process it from baseof.html ( with a partial ).
Please don't push it to later versions, it is open for 18 months.
So, I fighted with this myself some time ago, and figured out that I couldn't change the current behaviour without breaking stuff, so I added a new scratch variable.
Now there are:
.Store
.Scratch
On Page
. The .Store
will never be erased.
Thanks, nothing in the DOCS about .Store, looked in the source.
Seems not to work in lists templates.
This is the place where the sprites can have a big space impact.
Seems not to work in lists templates.
It's a new method on the Page
interface, so it should work everywhere.
Also, I'm working on a revised documentation with a complete reference section as I'm writing this.
I made a simple repo for testing on the scratch_issue branch at: https://github.com/EmpireJones/hugoBasicExample/tree/scratch_issue
I can reproduce the problem using this example with v0.101.0 and earlier. With v0.102.0 and later there are no problems.
There were 3 commits in v0.102.0 that affected LiveReload:
For anyone stumbling across this in the future...
1) Use .Page.Store
instead of .Page.Scratch
The Store method on a Page object creates a persistent scratch pad to store and manipulate data. In contrast with the Scratch method, the scratch pad created by the Store method is not reset on server rebuilds.
2) Make sure that the content is rendered before reading the Scratch/Store. For example, if you need a Scratch/Store value at the top of a template, before the content has been rendered, force content rendering with something like:
{{ $noop := .WordCount }}
{{ .Store.Get "foo" }}
There are several methods you can call to force content rendering. See this FAQ.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes
Issue Description
To reproduce:
hugo server
(i.e. with live reloading)Result:
Expected:
I made a simple repo for testing on the scratch_issue branch at: https://github.com/EmpireJones/hugoBasicExample/tree/scratch_issue
First Load (summary is generated from page's scratch):
After change occurs (summary is generated from page's scratch - but has no data):
https://github.com/gohugoio/hugo/issues/8255 seems similar, but I don't think it's discussing the exact same thing.