Skip to content

Commit 280de86

Browse files
committed
Add style for php 'blade' templates
1 parent 540fabe commit 280de86

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/reuse/_comment.py

+16
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,13 @@ class BibTexCommentStyle(CommentStyle):
272272

273273
MULTI_LINE = ("@Comment{", "", "}")
274274

275+
class BladeCommentStyle(CommentStyle):
276+
"""Laravel Blade Template comment style."""
277+
278+
_shorthand = "blade"
279+
280+
MULTI_LINE = ("{{--", "", "--}}")
281+
NEWLINE_AFTER = False
275282

276283
class CCommentStyle(CommentStyle):
277284
"""C comment style."""
@@ -646,6 +653,15 @@ class VimCommentStyle(CommentStyle):
646653
k.lower(): v for k, v in EXTENSION_COMMENT_STYLE_MAP.items()
647654
}
648655

656+
#: A map of (common) double file extensions against comment types.
657+
EXTENSIONS_COMMENT_STYLE_MAP = {
658+
".blade.php": BladeCommentStyle,
659+
}
660+
661+
EXTENSIONS_COMMENT_STYLE_MAP_LOWERCASE = {
662+
k.lower(): v for k, v in EXTENSIONS_COMMENT_STYLE_MAP.items()
663+
}
664+
649665
FILENAME_COMMENT_STYLE_MAP = {
650666
".bashrc": PythonCommentStyle,
651667
".coveragerc": PythonCommentStyle,

src/reuse/header.py

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from . import SpdxInfo
3636
from ._comment import (
3737
EXTENSION_COMMENT_STYLE_MAP_LOWERCASE,
38+
EXTENSIONS_COMMENT_STYLE_MAP_LOWERCASE,
3839
FILENAME_COMMENT_STYLE_MAP_LOWERCASE,
3940
NAME_STYLE_MAP,
4041
CCommentStyle,
@@ -330,6 +331,9 @@ def find_and_replace_header(
330331
def _get_comment_style(path: Path) -> Optional[CommentStyle]:
331332
"""Return value of CommentStyle detected for *path* or None."""
332333
style = FILENAME_COMMENT_STYLE_MAP_LOWERCASE.get(path.name.lower())
334+
if style is None:
335+
suffixes_lower = "".join(path.suffixes).lower()
336+
style = EXTENSIONS_COMMENT_STYLE_MAP_LOWERCASE.get(suffixes_lower)
333337
if style is None:
334338
style = EXTENSION_COMMENT_STYLE_MAP_LOWERCASE.get(path.suffix.lower())
335339
return style

0 commit comments

Comments
 (0)