@@ -41,19 +41,31 @@ const Pattern = function (
4141 */
4242 const pathObj = path . parse ( this . relPath ) ;
4343
44+ // We need to check for templates with a fileextension that contains multiple dots like e.g. .html.twig
45+ if (
46+ patternlab ?. config ?. patternExtension ?. includes ( '.' ) &&
47+ this . relPath . endsWith ( '.' + patternlab . config . patternExtension )
48+ ) {
49+ this . fileName = path . basename (
50+ this . relPath ,
51+ '.' + patternlab . config . patternExtension
52+ ) ; // e.g. 'colors'
53+ } else {
54+ this . fileName = pathObj . name ; // e.g. 'colors'
55+ }
56+ this . subdir = pathObj . dir ; // 'atoms/global'
57+ this . fileExtension = pathObj . ext ; // '.hbs'
58+
4459 const info = this . getPatternInfo (
4560 pathObj ,
4661 patternlab ,
4762 isPromoteToFlatPatternRun ||
4863 ( patternlab &&
4964 patternlab . config &&
50- patternlab . config . allPatternsAreDeeplyNested )
65+ patternlab . config . allPatternsAreDeeplyNested ) ,
66+ this . fileName
5167 ) ;
5268
53- this . fileName = pathObj . name ; // 'colors'
54- this . subdir = pathObj . dir ; // 'atoms/global'
55- this . fileExtension = pathObj . ext ; // '.mustache'
56-
5769 // TODO: Remove if block when dropping ordering by prefix and keep else code
5870 // (When we drop the info about the old ordering is deprecated)
5971 if (
@@ -345,15 +357,20 @@ Pattern.prototype = {
345357 *
346358 * @param pathObj path.parse() object containing useful path information
347359 */
348- getPatternInfo : ( pathObj , patternlab , isPromoteToFlatPatternRun ) => {
360+ getPatternInfo : (
361+ pathObj ,
362+ patternlab ,
363+ isPromoteToFlatPatternRun ,
364+ filename
365+ ) => {
349366 const info = {
350367 // colors(.mustache) is deeply nested in atoms-/global/colors
351368 patternlab : patternlab ,
352369 patternHasOwnDir : isPromoteToFlatPatternRun
353370 ? path . basename ( pathObj . dir ) . replace ( prefixMatcher , '' ) ===
354- pathObj . name . replace ( prefixMatcher , '' ) ||
371+ filename . replace ( prefixMatcher , '' ) ||
355372 path . basename ( pathObj . dir ) . replace ( prefixMatcher , '' ) ===
356- pathObj . name . split ( '~' ) [ 0 ] . replace ( prefixMatcher , '' )
373+ filename . split ( '~' ) [ 0 ] . replace ( prefixMatcher , '' )
357374 : false ,
358375 } ;
359376
0 commit comments