Skip to content
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

Question: Possibility to resolve template files without the file extension? #2232

Open
martenvdlp opened this issue Oct 2, 2023 · 2 comments

Comments

@martenvdlp
Copy link

Hello,

This question may seem somewhat odd so let me start out by giving you some context. In our projects we are using October CMS, which in turn runs on the Laravel framework (so not Symfony). October CMS uses the Twig template engine to render pages & components but uses the '.htm' extension instead of '.twig'.

We have installed this plugin because it allows us to specify the type of a variable inside a twig file, which in turn gives us some level of autocompletion/hinting when editing. However, we have another issue which we cannot solve without a modification in this plugin, hence the reason I have submitted this 'issue'.

In a Twig file it is possible to include other files by using the 'include' or 'embed' methods. This plugin 'autocompletes' the available template files for inclusion, which is great. However, when selecting the desired template file, the extension is added to the view path. Laravel does not allow this (as a list of possible view file extensions is used in the form of an 'allowlist'), and in turn an exception is thrown that the template file could not be found. I have specified an example below.

Not working (path hinted by the plugin with an ide-twig.json file in the root of the project):
{% include 'theme::badge.htm' %}

Working example but without the option to click the path and jump to the correct file or block:
{% include 'theme::badge' %}

Our question is: would you be willing to make a configuration option in the plugin that allows for the autocompletion to use view paths without the file extension so that it also works for Laravel / October CMS?

Thanks in advance for your time!

@Haehnchen
Copy link
Owner

i checked official docs and also some open projects, but for now its looks too custom. htm are even not real twig files

eg: https://github.com/OFFLINE-GmbH/oc-mall-theme/blob/master/pages/category.htm

@martenvdlp
Copy link
Author

@Haehnchen Thanks for taking the time to reply to this issue. We are aware that OctoberCMS has some degree of customisation in regard to regular twig files, but for this question that is not really relevant since WebStorm/PHPStorm does properly recognize Twig code inside these htm files. We, as OctoberCMS users (and also Laravel users, for that matter) would be able to get proper IDE path hinting if only the extensions were removed from the template filenames as per the example above. Would you be willing to make a configuration option for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants