@@ -385,7 +385,9 @@ class TemplateContent {
385
385
return [ cacheable , key , inputPathMap , useCache ] ;
386
386
}
387
387
388
- async compile ( str , bypassMarkdown , engineOverride ) {
388
+ async compile ( str , options = { } ) {
389
+ let { type, bypassMarkdown, engineOverride } = options ;
390
+
389
391
let tr = await this . getTemplateRender ( ) ;
390
392
391
393
if ( engineOverride !== undefined ) {
@@ -396,7 +398,7 @@ class TemplateContent {
396
398
}
397
399
398
400
if ( bypassMarkdown && ! this . engine . needsCompilation ( str ) ) {
399
- return async function ( ) {
401
+ return function ( ) {
400
402
return str ;
401
403
} ;
402
404
}
@@ -428,8 +430,9 @@ class TemplateContent {
428
430
}
429
431
}
430
432
431
- let templateBenchmark = this . bench . get ( "Template Compile" ) ;
432
- let inputPathBenchmark = this . bench . get ( `> Compile > ${ this . inputPath } ` ) ;
433
+ let typeStr = type ? ` ${ type } ` : "" ;
434
+ let templateBenchmark = this . bench . get ( `Template Compile${ typeStr } ` ) ;
435
+ let inputPathBenchmark = this . bench . get ( `> Compile${ typeStr } > ${ this . inputPath } ` ) ;
433
436
templateBenchmark . before ( ) ;
434
437
inputPathBenchmark . before ( ) ;
435
438
let fn = await tr . getCompiledTemplate ( str ) ;
@@ -491,15 +494,13 @@ class TemplateContent {
491
494
return this . _renderFunction ( str , data ) ;
492
495
}
493
496
494
- return this . _render ( str , data , true ) ;
497
+ return this . _render ( str , data , {
498
+ type : "Computed Data" ,
499
+ bypassMarkdown : true ,
500
+ } ) ;
495
501
}
496
502
497
503
async renderPermalink ( permalink , data ) {
498
- this . bench . get ( "(count) Render Permalink" ) . incrementCount ( ) ;
499
- this . bench
500
- . get ( `(count) > Render Permalink > ${ this . inputPath } ${ this . _getPaginationLogSuffix ( data ) } ` )
501
- . incrementCount ( ) ;
502
-
503
504
let permalinkCompilation = this . engine . permalinkNeedsCompilation ( permalink ) ;
504
505
505
506
// No string compilation:
@@ -528,11 +529,17 @@ class TemplateContent {
528
529
return this . _renderFunction ( permalink , data ) ;
529
530
}
530
531
531
- return this . _render ( permalink , data , true ) ;
532
+ return this . _render ( permalink , data , {
533
+ type : "Permalink" ,
534
+ bypassMarkdown : true ,
535
+ } ) ;
532
536
}
533
537
534
538
async render ( str , data , bypassMarkdown ) {
535
- return this . _render ( str , data , bypassMarkdown ) ;
539
+ return this . _render ( str , data , {
540
+ bypassMarkdown,
541
+ type : "" ,
542
+ } ) ;
536
543
}
537
544
538
545
_getPaginationLogSuffix ( data ) {
@@ -551,13 +558,19 @@ class TemplateContent {
551
558
return suffix . join ( "" ) ;
552
559
}
553
560
554
- async _render ( str , data , bypassMarkdown ) {
561
+ async _render ( str , data , options = { } ) {
562
+ let { bypassMarkdown, type } = options ;
563
+
555
564
try {
556
565
if ( bypassMarkdown && ! this . engine . needsCompilation ( str ) ) {
557
566
return str ;
558
567
}
559
568
560
- let fn = await this . compile ( str , bypassMarkdown , data [ this . config . keys . engineOverride ] ) ;
569
+ let fn = await this . compile ( str , {
570
+ bypassMarkdown,
571
+ engineOverride : data [ this . config . keys . engineOverride ] ,
572
+ type,
573
+ } ) ;
561
574
562
575
if ( fn === undefined ) {
563
576
return ;
@@ -567,29 +580,17 @@ class TemplateContent {
567
580
568
581
// Benchmark
569
582
let templateBenchmark = this . bench . get ( "Render" ) ;
570
- // Skip benchmark for each individual pagination entry (very busy output)
571
- let logRenderToOutputBenchmark = "pagination" in data ;
572
583
let inputPathBenchmark = this . bench . get (
573
- `> Render > ${ this . inputPath } ${ this . _getPaginationLogSuffix ( data ) } ` ,
584
+ `> Render${ type ? ` ${ type } ` : "" } > ${ this . inputPath } ${ this . _getPaginationLogSuffix ( data ) } ` ,
574
585
) ;
575
- let outputPathBenchmark ;
576
- if ( data . page ?. outputPath && logRenderToOutputBenchmark ) {
577
- outputPathBenchmark = this . bench . get ( `> Render to > ${ data . page . outputPath } ` ) ;
578
- }
579
586
580
587
templateBenchmark . before ( ) ;
581
588
if ( inputPathBenchmark ) {
582
589
inputPathBenchmark . before ( ) ;
583
590
}
584
- if ( outputPathBenchmark ) {
585
- outputPathBenchmark . before ( ) ;
586
- }
587
591
588
592
let rendered = await fn ( data ) ;
589
593
590
- if ( outputPathBenchmark ) {
591
- outputPathBenchmark . after ( ) ;
592
- }
593
594
if ( inputPathBenchmark ) {
594
595
inputPathBenchmark . after ( ) ;
595
596
}
0 commit comments