Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

VS Code extension with snippets, syntax highlighting, hover, and formatting for Twig.

License

NotificationsYou must be signed in to change notification settings

mblode/vscode-twig-language-2

Repository files navigation

VS Code Twig Language 2 👋

MaintenanceLicense: MIT

  • Syntax highlighting
  • Snippets
  • Emmet
  • Pretty Diff 3 Formatting
  • Hover

What has changed since version 1?

This extension doesnot have HTML Intellisense. If you need HTML Intellisense (which can be quite useful), please download my other Twig Language extension:https://github.com/mblode/vscode-twig-language.

I have created a new extension to fix the issues that I (and all of you) were having with file association, commenting and VS Code UI issues.

Simply add these lines to your VS Code settings to get emmet working and also to associate HTML files as twig syntax.

"files.associations": {    "*.html": "twig"},"emmet.includeLanguages": {    "twig": "html"},

Installation

Install through Visual Studio Code extensions. Search forTwig Language 2

Visual Studio Code Market Place: Twig Language 2

Configuration

Restart VS Code after making changes to Twig Language 2 extension settings.

Documentation

Twig Language 2 is a Visual Studio Code extension that provides snippets, syntax highlighting, hover, and formatting for the Twig file format.

Twig syntax highlighting and language support

This extension provides language support for the Twig syntax.

Code formatter/beautifier for Twig files

Using PrettyDiff, this extension implements the only working code formatter for Twig files in VS Code.

Information about Twig code on hover

VS Code Twig language 2 shows information about the symbol/object that's below the mouse cursor when you hover within Twig files.

Craft CMS/Twig code snippets

Adds a set of Craft CMS/Twig code snippets to use in your Twig templates.

Generic Triggers

do                {%do ... %}extends           {%extends'template' %}from              {%from'template'import'macro' %}import            {%import'template'asname %}importself        {%import_selfasname %}inc, include      {%include'template' %}incp              {%include'template'withparams %}inckv             {%include'template'with {key:value } %}use               {%use'template' %}autoescape        {%autoescape'type' %}...{%endautoescape %}block, blockb     {%blockname %} ... {%endblock %}blockf            {{block('...') }}embed             {%embed"template" %}...{%endembed %}filter, filterb   {%filter name %} ... {%endfilter %}macro             {%macro name(params) %}...{%endmacro %}set, setb         {%setvar=value %}spaceless         {%spaceless %}...{%endspaceless %}verbatim          {%verbatim %}...{%endverbatim %}if, ifb           {%ifcondition %} ... {%endif %}ife               {%ifcondition %} ... {%else %} ... {%endif %}for               {%foriteminseq %} ... {%endfor %}fore              {%foriteminseq %} ... {%else %} ... {%endfor %}else              {%else %}endif             {%endif %}endfor            {%endfor %}endset            {%endset %}endblock          {%endblock %}endfilter         {%endfilter %}endautoescape     {%endautoescape %}endembed          {%endembed %}endfilter         {%endfilter %}endmacro          {%endmacro %}endspaceless      {%endspaceless %}endverbatim       {%endverbatim %}

Craft Triggers

asset                    craft.assets.one()assets, assetso          craft.assets loopcategories, categorieso  craft.categories loopentries, entrieso        craft.entries loopfeed                     craft.app.feeds.getFeedItems loopt                        | treplace                  | replace('search', 'replace')replacex                 | replace('/(search)/i', 'replace')split                    | split('\n')tags, tagso              craft.tags loopusers, userso            craft.users loopcache                    {%cache %}...{%endcache %}children                 {%children %}exit                     {%exit404 %}ifchildren               {%ifchildren %}...{%endifchildren %}css                      {%css %}...{%endcss %}registercssfile          {%do view.registerCssFile("/resources/css/global.css") %}js                       {%js %}...{%endjs %}registerjsfile           {%do view.registerJsFile("/resources/js/global.js") %}matrix, matrixif         Basic Matrix field loop using if statementsmatrixifelse             Basic Matrix field loop using if/elseifmatrixswitch             Basic Matrix field loop using switchnav                      {%naviteminitems %}...{%endnav %}paginate                 Outputs example of pagination and prev/next linksredirect                 {%redirect'login' %}requirelogin             {%requireLogin %}requirepermission        {%requirePermission"spendTheNight" %}switch                   {%switchvariable %}...{%endswitch %}csrf                     {{ csrfInput() }}endbody                  {{ endBody() }}head                     {{ head() }}getparam                 craft.app.request.getParam()getbodyparam             craft.app.request.getBodyParam()getqueryparam            craft.app.request.getQueryParam()getsegment               craft.app.request.getSegment()case                     {%case"value" %}endcache                 {%endcache %}endifchildren            {%endifchildren %}endcss                   {%endcss %}endjs                    {%endjs %}endnav                   {%endnav %}ceil                     ceil()floor                    floor()max                      max()min                      min()shuffle                  shuffle()random                   random()round                    num | round()url, urla                url('path'), url('path', params, 'http', false)rss                      Example rss feeddd                       <pre>{{dump() }}</pre>{%exit %}dump                     <pre>{{dump() }}</pre>

Example Forms

formlogin                Example login formformuserprofile          Example user profile formformuserregistration     Example user registration formformforgotpassword       Example forgot password formformsetpassword          Example set password formformsearch               Example search formformsearchresults        Example search form results

Reference Hints

info            All craft.assets properties and template tagsinfo            All craft.crategories properties and template tagsinfo            All craft.config properties and template tagsinfo            All craft.entries properties and template tagsinfo            All craft.feeds properties and template tagsinfo            All craft.fields properties and template tagsinfo            All craft.globals properties and template tagsinfo            All craft.request properties and template tagsinfo            All craft.sections properties and template tagsinfo            All craft.session properties and template tagsinfo            All craft.tags properties and template tagsinfo            All craft.users properties and template tagsinfo            All craft globals (site info, date, users, template tags)

Author

👤Matthew Blode

🤝 Contributing

Contributions, issues and feature requests are welcome !
Feel free to checkissues page.

Show your support

Give a ⭐️ if this project helped you !

📝 License

Copyright © 2019Matthew Blode.
This project isMIT licensed.

About

VS Code extension with snippets, syntax highlighting, hover, and formatting for Twig.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Contributors9


[8]ページ先頭

©2009-2025 Movatter.jp