Comments (6)
Nice idea. I'll have to look into it a bit to see if/how it's possible to implement. Or welcome reviewing the pull request if you want to take a shot at it! ;-)
from craft-twig.tmbundle.
@BenParizek Whil I have not yet poked into .tmLanguage files etc, I think this is not so hard from what I can see here: https://github.com/fcgrx/ExpressionEngine2-Sublime-Text-3-Bundle/blob/master/Syntaxes/ExpressionEngine.tmLanguage - basically you would add a block like this I think
<key>javascript</key>
<dict>
<key>begin</key>
<string>(?:^\s+)?<((?i:script))\b(?![^>]*/>)[^>]*>?</string>
<key>captures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>entity.name.tag.html</string>
</dict>
</dict>
<key>end</key>
<string></((?i:script))>(?:\s*)?</string>
<key>name</key>
<string>source.js.embedded.html</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#embedded-code</string>
</dict>
<dict>
<key>include</key>
<string>source.js.jquery</string>
</dict>
<dict>
<key>include</key>
<string>source.js</string>
</dict>
</array>
</dict>
and similarly with the css block in the above link...
...I too would find it very handy :) it's hard on the eyes seeing all that plain text at the bottom of a nice template ;)
from craft-twig.tmbundle.
I think we'll be able to add some support for this in the next release.
I believe this is a bit tricker than the above example leads on. <script>
is a predicable pattern for a regex to grab but the {% includeCss anyCustomVariableName %}
syntax has a random custom variable in the middle of it. Lookbehinds and lookaheads don't support wildcard selection like .*, or at least I haven't found a way around this yet.
So, currently, it looks like we can at least support a single syntax where we can predict the variable like below (where css
and js
are the default, supported variable names):
{% set css %}{% endset %}
{% set js %}{% endset %}
from craft-twig.tmbundle.
Well that's certainly a big improvement, I'd think most embedded mini scripts would be done with a set followed by an include anyway? Thanks for looking at it and indeed the work so far - I am finding the shortcuts etc very handy!
(also - while you're at it - highlighting for switch/case/endswitch if you'll accept a cheeky inline feature request!!)
from craft-twig.tmbundle.
Just added these locally. The next release will support:
CSS Syntax Highlighting for a set css
tag:
{% set css %}{% endset %}
JS Syntax Highlighting for a set js
tag:
{% set js %}{% endset %}
Syntax highlighting for switch/case/endswitch
, even though it was a cheeky inline feature request ;-)
from craft-twig.tmbundle.
This is now released: https://github.com/BarrelStrength/Craft-Twig.tmbundle/releases
from craft-twig.tmbundle.
Related Issues (20)
- Add 'switch' as a snippet HOT 6
- Add syntax highlighting support for {% includecss %}, {% includehirescss %}, and {% includejs %} tag pairs. HOT 1
- Add support for common plugin migrations
- Code highlighting less scannable HOT 4
- Little bug in includejs completion HOT 1
- Sublime Text throws regex error HOT 8
- snippets should have tabs instead of spaces HOT 2
- Error loading syntax file HOT 2
- Does not activate in PHPStorm version 2017.1.2 HOT 1
- Extra bracket in include - {% include 'template' }%} HOT 2
- syntax highlighting in js and css tags HOT 2
- Add Craft 3 support HOT 3
- Tab trigger stopped working HOT 5
- Extend "dd" into {% dd %} twig Tag HOT 1
- Extending "##" into comment does not work HOT 1
- autocomplete within brackets
- Add to Sublime Package Control HOT 3
- bundle lacks mandatory keys HOT 5
- Twig syntax not auto selected. HOT 1
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 craft-twig.tmbundle.