You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem:
I need to be able to use different liquid templates based on runtime information (cookie, user-agent, etc.). Similar to DisplayMode in ASP.NET.
Whilst it is possible to provide a custom File Provider which contains this logic and returns appropriate templates, the Template Cache in FluidViewRenderer just caches templates based on path - so renders my logic useless.
Possible change
Add a new delegate to FluidViewEngineOptions that takes the template path and returns a Template Cache key (string)
Use this delegate (if present) in GetFluidTemplateAsync to generate the key for each template in the Template Cache
e.g.
// Allow templates to be cached by external factors
// Typically the rule would match any rules in custom IFileProvider implementations
// e.g. Serve different templates based on Authentication status / User Agent etc.
string cacheKey = path;
if (_fluidViewEngineOptions.TemplateCacheKeyProvider!=null)
{
cacheKey = _fluidViewEngineOptions.TemplateCacheKeyProvider.Invoke(path);
}
if (cache.TemplateCache.TryGetValue(cacheKey, out var template))
{
return template;
}
template = await ParseLiquidFileAsync(path, fileProvider, includeViewStarts);
cache.TemplateCache[cacheKey] = template;
return template;
The text was updated successfully, but these errors were encountered:
Problem:
I need to be able to use different liquid templates based on runtime information (cookie, user-agent, etc.). Similar to
DisplayMode
in ASP.NET.Whilst it is possible to provide a custom File Provider which contains this logic and returns appropriate templates, the Template Cache in
FluidViewRenderer
just caches templates based on path - so renders my logic useless.Possible change
FluidViewEngineOptions
that takes the template path and returns a Template Cache key (string)GetFluidTemplateAsync
to generate the key for each template in the Template Cachee.g.
The text was updated successfully, but these errors were encountered: