sebastienros/fluid

Fluid View engine does not work with Windows-style paths corretly

JustusGreiberORGADATA opened this issue · 2 comments

The following code does not work on a Windows machine properly, because the path is generated with the Windows-style path seperator (MemberInvitation\MemberInvitation.liquid) but the discovery code for partials, layouts and viewstarts can't deal with the backslash.

var path = Path.Join("MemberInvitation", "MemberInvitation.liquid");
await fluidViewRenderer.RenderViewAsync(stringWriter, path, templateContext);

For example the code here expects the path seperator to be the forward slash:

while (!String.IsNullOrEmpty(viewPath))
{
if (index == -1)
{
return viewStarts;
}
index = viewPath.LastIndexOf('/', index);
viewPath = viewPath.Substring(0, index + 1);
var viewStartPath = viewPath + Constants.ViewStartFilename;
var viewStartInfo = fileProvider.GetFileInfo(viewStartPath);
if (viewStartInfo.Exists)
{
viewStarts.Add(viewStartPath);
}
index = index - 1;
}
viewStarts.Reverse();
return viewStarts;

I'm wondering how it works before?

Before there was no layout path resolution algorithm like that. It just took the layout path directly from the root of the file provider. It was changed here:

26b9311#diff-87667ed94ee7cf341f18d062a1184f52f622dd055e657180b4eeab7a4e02c412R53-R61