@@ -69,6 +69,7 @@ import type { PugFramework } from './options/pug-framework';
6969import type { PugIdNotation } from './options/pug-id-notation' ;
7070import { isAngularAction , isAngularBinding , isAngularDirective , isAngularInterpolation } from './utils/angular' ;
7171import {
72+ detectFramework ,
7273 handleBracketSpacing ,
7374 isMultilineInterpolation ,
7475 isQuoted ,
@@ -155,6 +156,8 @@ export class PugPrinter {
155156 private readonly indentString : string ;
156157 private indentLevel : number = 0 ;
157158
159+ private readonly framework : PugFramework = 'none' ;
160+
158161 private readonly quotes : "'" | '"' ;
159162 private readonly otherQuotes : "'" | '"' ;
160163
@@ -199,6 +202,7 @@ export class PugPrinter {
199202 if ( options . pugSingleFileComponentIndentation ) {
200203 this . indentLevel ++ ;
201204 }
205+ this . framework = options . pugFramework !== 'none' ? options . pugFramework : detectFramework ( ) ;
202206
203207 this . quotes = this . options . pugSingleQuote ? "'" : '"' ;
204208 this . otherQuotes = this . options . pugSingleQuote ? '"' : "'" ;
@@ -371,7 +375,7 @@ export class PugPrinter {
371375
372376 private frameworkFormat ( code : string ) : string {
373377 const options : Options = { ...this . codeInterpolationOptions } ;
374- switch ( this . options . pugFramework ) {
378+ switch ( this . framework ) {
375379 case 'angular' :
376380 options . parser = '__ng_interpolation' ;
377381 break ;
@@ -421,7 +425,6 @@ export class PugPrinter {
421425 code = this . frameworkFormat ( code ) ;
422426 }
423427 } catch ( error : unknown ) {
424- const { pugFramework } = this . options ;
425428 if ( typeof error === 'string' ) {
426429 if ( error . includes ( 'Unexpected token Lexer Error' ) ) {
427430 if ( ! error . includes ( 'Unexpected character [`]' ) ) {
@@ -433,21 +436,21 @@ export class PugPrinter {
433436 `code: \`${ code . trim ( ) } \``
434437 ) ;
435438 } else if ( error . includes ( "Unexpected token '('" ) ) {
436- if ( pugFramework !== 'vue' ) {
439+ if ( this . framework !== 'vue' ) {
437440 logger . warn (
438441 '[PugPrinter:formatText]: Found unexpected token `(`.' ,
439442 `code: \`${ code . trim ( ) } \``
440443 ) ;
441444 }
442445 } else if ( error . includes ( 'Missing expected `)`' ) ) {
443- if ( pugFramework !== 'vue' ) {
446+ if ( this . framework !== 'vue' ) {
444447 logger . warn (
445448 '[PugPrinter:formatText]: Missing expected `)`.' ,
446449 `code: \`${ code . trim ( ) } \``
447450 ) ;
448451 }
449452 } else if ( error . includes ( 'Missing expected `:`' ) ) {
450- if ( pugFramework !== 'vue' ) {
453+ if ( this . framework !== 'vue' ) {
451454 logger . warn (
452455 '[PugPrinter:formatText]: Missing expected `:`.' ,
453456 `code: \`${ code . trim ( ) } \``
0 commit comments