]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0635: filetype: SuperHTML template files not recognized v9.1.0635
authorEliSauder <24995216+EliSauder@users.noreply.github.com>
Sun, 28 Jul 2024 19:28:11 +0000 (21:28 +0200)
committerChristian Brabandt <cb@256bit.org>
Sun, 28 Jul 2024 19:28:11 +0000 (21:28 +0200)
Problem:  filetype: SuperHTML template files not recognized
Solution: Update the filetype detection code to detect '*.shtml' either
          as HTML (Server Side Includes) or SuperHTML (template files)
          (EliSauder)

related: #15355
related: #15367

Signed-off-by: EliSauder <24995216+EliSauder@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/autoload/dist/ft.vim
runtime/filetype.vim
src/testdir/test_filetype.vim
src/version.c

index e53cdacbe34c88ada5a6efc27ba5ddb1effb9203..c8942eb3d114a589cfb8815d366b3b529c8c8e38 100644 (file)
@@ -421,7 +421,6 @@ export def FThtml()
       setf htmlangular
       return
     endif
-
     # Check for XHTML
     if getline(n) =~ '\<DTD\s\+XHTML\s'
       setf xhtml
@@ -432,6 +431,11 @@ export def FThtml()
       setf htmldjango
       return
     endif
+    # Check for SuperHTML
+    if getline(n) =~ '<extend\|<super>'
+        setf superhtml
+        return
+    endif
     n += 1
   endwhile
   setf FALLBACK html
index d02826578e29a00b97b9877fde27d53dc18c911a..bdf591ac7b1e0cbd510f21f44e2459d2ae283eba 100644 (file)
@@ -1039,7 +1039,7 @@ au BufNewFile,BufRead *.t.html                    setf tilde
 " Translate shell
 au BufNewFile,BufRead init.trans,*/etc/translate-shell,.trans  setf clojure
 
-" HTML (.shtml and .stm for server side)
+" HTML (.stm for server side, .shtml is server-side or superhtml)
 au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm  call dist#ft#FThtml()
 au BufNewFile,BufRead *.cshtml                 setf html
 
index f8b3ea872b1d44fcc4794b6c42c450b7702fd1d8..3aa3e97f4eb1d03d6b10da94f5852a3b26b66931 100644 (file)
@@ -1603,6 +1603,38 @@ func Test_html_file()
   call assert_equal('htmldjango', &filetype)
   bwipe!
 
+  " Super html layout
+  let content = ['<extend template="base.shtml">',
+        \ '<title id="title" var="$page.title"></title>',
+        \ '<head id="head"></head>',
+        \ '<div id="content">',
+        \ '</div>']
+  call writefile(content, 'Xfile.shtml', 'D')
+  split Xfile.shtml
+  call assert_equal('superhtml', &filetype)
+  bwipe!
+
+  " Super html template
+  let content = ['<!DOCTYPE html>',
+        \ '<html>',
+        \ '  <head id="head">',
+        \ '    <title id="title">',
+        \ '      <super>',
+        \ '      suffix',
+        \ '    </title>',
+        \ '    <super>',
+        \ '  </head>',
+        \ '  <body>',
+        \ '    <div id="content">',
+        \ '      <super>',
+        \ '    </div>',
+        \ '  </body>',
+        \ '</html>']
+  call writefile(content, 'Xfile.shtml', 'D')
+  split Xfile.shtml
+  call assert_equal('superhtml', &filetype)
+  bwipe!
+
   " regular HTML
   let content = ['<!DOCTYPE html>', '<html>', '    <head>Foobar</head>', '    <body>Content', '    </body>', '</html>']
   call writefile(content, 'Xfile.html', 'D')
index 6520422955da491adf12b74bcff3335bc2e71c7e..a321cc53e3523b7ddd1f14103d3aa700af1cb980 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    635,
 /**/
     634,
 /**/