Closed foscomputerservices closed 6 years ago
TemplateData.hashValue should be unique across all instances. The problem is that TemplateData doesn't conform to the Hashable
protocol.
@foscomputerservices conforming TemplateData
to Hashable
(and implementing a suitably unique tasing algorithm - if only we were on Swift 4.2) should fix this issue and is probably a better approach.
Yeah, should be able to use a hasher and just combine into all of the properties for pre Swift 4.2.
This has been fixed in: https://github.com/vapor/template-kit/pull/31
I've also improved the render methods that accept file paths to not read files from disk if the AST is cached.
Data.hashValue is not guaranteed to be unique across all Data instances. This can lead to the cache returning the wrong template.
This change uses the file name instead of Data.hashValue to key the cache. This change also means that calls to TemplateRenderer.render(template:context:file:), where the file parameter is defaulted, will no longer be cached.