Open gebeer opened 9 months ago
Hi, I've not (yet) tested it outside Nette, but AFAIK the extension shouldn't really be dependent on it in any way.
Type hinting via specifying {templateType ...}
is now pretty well supported, but also shouldn't be a requirement.
As long as you specify some (existing) types for some variables in a .latte
file via tag {var MyNamespace\MyClass $object = ...}
or via tag {varType MyNamespace\MyClass $object}
, the extension should be able pick that up.
If it doesn't work for you, is there maybe anything useful visible in the Help > Toggle Developer Tools
JS console in vscode? :thinking:
Here viewing Latte file in https://github.com/ApiGen/ApiGen codebase, as an example of working vscode-latte-lang
extension outside of Nette framework app:
Thx @smuuf it's strange. It does not work for me:
Any ideas what we could be missing?
... 🤔
As I asked the original issue author - is there maybe some error visible in vscode's JS console (in Developer Tools)? Also what dev environment do you have? Pure Windows? Windows/WSL? Linux?
... 🤔
As I asked the original issue author - is there maybe some error visible in vscode's JS console (in Developer Tools)? Also what dev environment do you have? Pure Windows? Windows/WSL? Linux?
Thank you for looking into this. The described behaviour happens on both, Windows 11 and Linux. In VSCode, VSCodium and Cursor Editors (both forks of VSCode) No relevant errors/warnings in devtools. Here some screens from Cursor Editor running on Linux.
Thx @smuuf what console are you talking about? One of these? Sorry I'm using VSCode every day but only as a user, I have never touched anything beyond settings ;)
The screenshot is from cursor, here's the same with vscode:
I'm on Mac as you can see :)
Thx for your help @smuuf !
@gebeer Are you sure you have the correct fully qualified class name in the template? In your screenshot I see RockPageBuilder\Model3D
vs RockPageBuilderBlock\Model3D
.
@smuuf I think you are right here, but I tried the same with the repo you linked to. And these kind of typos only happen because the IDE does not suggest the correct type as it would in PHP:
Not sure if your extension should also add autocomplete for vartypes?
@gebeer Are you sure you have the correct fully qualified class name in the template? In your screenshot I see
RockPageBuilder\Model3D
vsRockPageBuilderBlock\Model3D
.
Doesn't make a difference:
Just installed the extension, amazing work, thanks a lot for this! Just wanted to add a note that type hints seem to be working correctly in the latest version, but best to check in with @gebeer if he's still seeing the issue.
@daun it's still not working for me and has never been :( Any ideas?
@BernhardBaumrock Just guessing: Might be an issue with intelephense, if that's used to gather type information? I remember having issues with it not properly starting. But if you're seeing the typehints in regular PHP files, that might not be it. Also, could be a compatibility issue with another extension — disabling all extensions except this one might give some clues.
Thank you for the great extension.
I can't get it to work when using Latte outside the Nette Framework.
Is the definition of a FooTemplateParameters class following the example at https://latte.nette.org/en/type-system required for type hinting to work?
I guess yes. Just wanted to make sure.