Add Laravel Blade language support (#1353)

- Detect Blade by .blade extension and .blade.php compound suffix
- Generic path_suffixes field for any future compound-extension language;
  matched in from_path before extension lookup so .blade.php wins over PHP
- Recognise Blade ({{-- --}}) and HTML (<!-- -->) multi-line comments
- Sanitise auto-generated test idents so blade.blade.php produces a
  valid Rust function name
- Add blade.blade.php fixture covering both comment styles
This commit is contained in:
Ben Faerber
2026-05-06 18:42:32 +02:00
committed by GitHub
parent 505d6481c9
commit fa44e51940
4 changed files with 47 additions and 1 deletions
+7 -1
View File
@@ -109,7 +109,13 @@ use super::*;
let path = path.path();
let root = std::path::PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
let name = path.file_stem().unwrap().to_str().unwrap().to_lowercase();
let name = path
.file_stem()
.unwrap()
.to_str()
.unwrap()
.to_lowercase()
.replace('.', "_");
if name == "jupyter" {
continue;
+7
View File
@@ -190,6 +190,13 @@
"quotes": [["\\\"", "\\\""], ["'", "'"]],
"extensions": ["bb", "bbclass", "bbappend", "inc"]
},
"Blade": {
"name": "Blade",
"multi_line_comments": [["{{--", "--}}"], ["<!--", "-->"]],
"quotes": [["\\\"", "\\\""], ["'", "'"]],
"extensions": ["blade"],
"path_suffixes": [".blade.php"]
},
"Bqn": {
"name": "BQN",
"line_comment": ["#"],
+10
View File
@@ -290,6 +290,16 @@ impl LanguageType {
{%- endfor %}
_ => ()
}
{% for key, value in languages -%}
{%- if value.path_suffixes -%}
{%- for suffix in value.path_suffixes %}
if filename.ends_with("{{suffix}}") {
return Some({{key}});
}
{%- endfor %}
{% endif -%}
{%- endfor %}
}
match fsutils::get_extension(entry) {
+23
View File
@@ -0,0 +1,23 @@
{{-- 23 lines 15 code 5 comments 3 blanks --}}
{{--
A welcome page demonstrating Blade syntax.
--}}
@extends('layouts.app')
@section('content')
<!-- Page header -->
<div class="container">
<h1>{{ $title }}</h1>
@if ($users->isNotEmpty())
<ul class="list-group">
@foreach ($users as $user)
<li>{{ $user->name }}</li>
@endforeach
</ul>
@else
<p>No users found.</p>
@endif
</div>
@endsection