Comments (10)
@arvislacis thanks for the report - yes, I've encountered this issue too.
The reason for this is due to an intrinsic design decision of the syntax highlighter that VSCode uses - TextMate. TextMate is performant for one simple reason - it applies syntax per line, not over the entire document. You can set boundaries for embedded languages (in our case, INI and PHP), but ultimately, the first match always wins unless it is ended. There is no mechanism to deny a section once it has begun - it will apply that section until it hits the end boundary, or it hits the end of the document.
We have set up our syntax (the wintercms
language) to always assume that there is always an INI section, there may be a PHP section, and the HTML/Twig section will always be last. With this assumption, our syntax highlighter works flawlessly with compound templates - the two attempts that have tried to bring language support to October require something to be added to the template for all three languages to work. But this does have the effect that in straight HTML/Twig templates, these are interpreted as INI files because it never hits the "end" boundary for that section (the ==
characters).
I'm in two minds on whether this needs to be fixed - on the one hand, our templates always have these boundaries if they are created through Winter, so implicitly this is the correct format, but on the other hand, it's not a requirement - straight HTML/Twig files load up just fine in Winter.
It could be that we simply recommend people start their templates with two equals (==
) and then go ahead with the HTML/Twig code, or we recommend people who want to edit a straight HTML file switch the language to the "Winter CMS Template (Twig)" language. Happy to hear other thoughts on this though.
@bennothommo is wintercms-twig a mode that's different from twig and wintercms?
It's our version of the Twig language, which also adds highlighting for our functions and filters too. It has to be specified in order for the embedded Twig in our compound templates (powered by the Winter CMS Template language) to work.
from vscode-extension.
Yeah, it should be that, but I'll test it first before changing it :)
from vscode-extension.
At least it worked for me without problems. :) And also, if this extension is mostly managing all Twig syntax etc. of Winter CMS projects then I don't see point of using twig
(probably another extension) just for component partials.
from vscode-extension.
@arvislacis All new WinterCMS projects have smart extension mapping by default, but if you'd like to add it to your existing projects you can copy the .vscode/settings.json
file from the main repo to your project: https://github.com/wintercms/winter/blob/develop/.vscode/settings.json.
from vscode-extension.
It's our version of the Twig language, which also adds highlighting for our functions and filters too. It has to be specified in order for the embedded Twig in our compound templates (powered by the Winter CMS Template language) to work.
If that's the case then shouldn't https://github.com/wintercms/winter/blob/cf5ae34f5adfa17f18d7f8f381a2fc73330b744a/.vscode/settings.json#L14 be changed to wintercms-twig
?
from vscode-extension.
@arvislacis thanks for the reminder. Will fix that in the repo. :)
from vscode-extension.
@LukeTowers Nice, thanks for the clarification. Yeah, my projects are from the previous year so these settings are not up to date. But, anyways, maybe there could be some note in extension's README file about this...
from vscode-extension.
@LukeTowers I looked into the Winter CMS config you mentioned and now I have question about this:
Shouldn't it be wintercms-twig
instead of twig
?
from vscode-extension.
Component partials are only Twig, they don't have INI or PHP sections.
@bennothommo is wintercms-twig a mode that's different from twig and wintercms?
from vscode-extension.
@bennothommo Did you take look at that https://github.com/wintercms/winter/blob/869a718feeba4da82b06d92a0b7f547747ef4af7/.vscode/settings.json#L14 config?
from vscode-extension.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-extension.