### Run Tree-sitter Playground Source: https://github.com/emranmr/tree-sitter-blade/blob/main/CONTRIBUTING.md Use this command to start the tree-sitter playground for testing new syntax rules in your browser. ```bash deno run start ``` -------------------------------- ### Envoy Directives Example Source: https://github.com/emranmr/tree-sitter-blade/blob/main/test/corpus/envoy.txt Demonstrates the usage of multiple Envoy notification directives within a single @finished block. ```blade @finished @microsoftTeams('webhook-url') @slack('webhook-url', '#bots', 'Hello, Slack.') @discord('discord-webhook-url') @endfinished ``` -------------------------------- ### Using @svg directive Source: https://github.com/emranmr/tree-sitter-blade/blob/main/test/corpus/inline-directives.txt Provides an example of how to render an SVG icon by name using the @svg directive. ```blade @svg('name') ``` -------------------------------- ### Blade @switch Statement Example Source: https://github.com/emranmr/tree-sitter-blade/blob/main/test/corpus/switch-statements.txt Demonstrates the basic usage of the @switch directive with multiple @case and a @default clause. Use @break to exit the switch block after a matching case. ```blade @switch($i) @case(1) First case... @break @case(2) Second case... @break @case(3) @case(4) Third and fourth case... @break @default Default case... @endswitch ``` -------------------------------- ### Using @prependOnce Directive Source: https://github.com/emranmr/tree-sitter-blade/blob/main/test/corpus/stacks.txt The @prependOnce directive adds content to the beginning of a named stack only if it hasn't been prepended before. This ensures unique content at the start of a stack. ```blade @prependOnce('test') prependOnce @endPrependOnce ``` ```tree-sitter (document (stack (directive_start) (parameter) (text) (directive_end))) ``` -------------------------------- ### Blade @assets Directive Source: https://github.com/emranmr/tree-sitter-blade/blob/main/test/corpus/nested-directives.txt Includes external assets like JavaScript and CSS files. This example shows how to load Pikaday JS and its CSS. ```blade @assets @endassets ``` -------------------------------- ### Blade @script Directive Source: https://github.com/emranmr/tree-sitter-blade/blob/main/test/corpus/nested-directives.txt Embeds JavaScript code within a Blade template, often used for Livewire component-specific scripts. The setInterval example demonstrates refreshing Livewire data. ```blade @script @endscript ``` -------------------------------- ### Including WireUI scripts with nonce Source: https://github.com/emranmr/tree-sitter-blade/blob/main/test/corpus/inline-directives.txt Demonstrates how to include WireUI scripts, optionally providing a nonce for CSP. ```blade @wireUiScripts(['nonce': 'csp-token']) ``` ```blade @wireUiScripts(['nonce': 'csp-token', 'foo' => true]) ``` -------------------------------- ### Run Grammar Unit Tests Source: https://github.com/emranmr/tree-sitter-blade/blob/main/CONTRIBUTING.md Execute this command to run the unit tests for the grammar to ensure new rules do not break existing ones. ```bash deno run test-grammar ``` -------------------------------- ### Package Component Parsing Source: https://github.com/emranmr/tree-sitter-blade/blob/main/test/corpus/components.txt Shows how package components with namespace separators are parsed. ```tree-sitter (document (element (self_closing_tag (tag_name))) (element (self_closing_tag (tag_name)))) ``` -------------------------------- ### Define and Execute Envoy Tasks Source: https://github.com/emranmr/tree-sitter-blade/blob/main/test/corpus/envoy.txt Define a task named 'deploy' that runs on the 'web' server. Includes commands for changing directory, conditionally pulling from git, and migrating the database. ```blade @task('deploy', ['on' => 'web']) cd /home/user/example.com @if ($branch) git pull origin {{ $branch }} @endif php artisan migrate --force @endtask ``` -------------------------------- ### Laravel Welcome Page with Vite Integration Source: https://github.com/emranmr/tree-sitter-blade/blob/main/test/corpus/html-blade.txt A standard Laravel welcome page demonstrating conditional asset inclusion using Vite. It checks for the existence of manifest.json or the hot file to determine the build environment. ```blade