-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
{% render "filename" %} with custom extensions #581
Comments
I think it's fine to keep it as its. In your case, you can customize |
but this implies using MvcViewEngine, right? My app is a console one. when creating the parser, we already provide a IFileProvider to mostly inform the "root" path. the proposed solution is to implement some kind of virtual method to search for and resolve the right filename. If the MVC already provides a bit of this, would be great to migrate the core into the parser itself. In short: there is a use case for using kinda some of the MVC functionality without the need for the full-blown MVC framework. |
Bumping this topic, |
There is already an https://github.com/sebastienros/fluid/blob/main/Fluid/TemplateOptions.cs#L19-L22 So you can set it as default options or per template (in |
Thank you, that'll work. For some reason I missed the usage file provider in I'll post an update after I finish the implementation. |
@sebastienros and @mihail-brinza, if (!relativePath.EndsWith(ViewExtension, StringComparison.OrdinalIgnoreCase))
{
relativePath += ViewExtension;
}
...
var fileProvider = context.Options.FileProvider;
var fileInfo = fileProvider.GetFileInfo(relativePath); I would suggest make |
@mihail-brinza, as a workaround, it reverts the ".liquid"
Then use: TemplateOptions.FileProvider = new LiquidPhysicalFileProvider(root); |
@brmassa What about a A concern I have is for security reasons, where one could request a file that is not liquid... The |
Changing the default value extension value would require the c# configuration, so, deliberate option from the dev. (For backward compatibility, it should be set ".liquid" by default) Liquid could be implemented for any text output. Html, xnl, markdown, Json, etc... By having partials as "myfile.json", any IDE can properly highlight and parse it as Json instead "myfile.json.liquid" Also, I don't see much risk on inputting an arbitrary file. File extensions don't prevent anything. Fluid, of course, must check if it's a valid txt file, but I guess it it's done now anyway. |
Currently,
{% render "filename" %}
will only look for a file calledfilename.liquid
. However, would be great to make it use the IFileProvider to figure out the proper file, allowing users to customize this behavior.It's particularly good if the liquid template is actually creating a known format in IDE, like HTML, CSS. Using the destination format extension like
filename.html
,filename.css
,filename.liquid.html
would allow the IDE to highlight the code properly.it's somewhat related to #357
probable targets:
The text was updated successfully, but these errors were encountered: