@@ -80,12 +80,16 @@ public TemplateEngine(IEnumerable<string> templates, IDictionary<string, string>
8080
8181 HandlebarsBlockHelper ifTemplateHelper = ( output , options , context , args ) =>
8282 {
83- var val = this . engine . Compile ( "{{> " + args [ 0 ] . ToString ( ) + "}}" ) ( ( object ) context ) ? . ToString ( ) ? . Trim ( ) ;
84- var isSet = ! string . IsNullOrWhiteSpace ( val ) ;
85-
86- if ( args . Length > 1 )
83+ var isSet = false ;
84+ if ( registerTemplates . Contains ( args [ 0 ] . ToString ( ) , StringComparer . OrdinalIgnoreCase ) ) // need to check if its case insenative
8785 {
88- isSet = val . Equals ( args [ 1 ] ? . ToString ( ) ) ;
86+ var val = this . engine . Compile ( "{{> " + args [ 0 ] . ToString ( ) + "}}" ) ( ( object ) context ) ? . ToString ( ) ? . Trim ( ) ;
87+ isSet = ! string . IsNullOrWhiteSpace ( val ) ;
88+
89+ if ( args . Length > 1 )
90+ {
91+ isSet = val . Equals ( args [ 1 ] ? . ToString ( ) ) ;
92+ }
8993 }
9094
9195 if ( isSet )
@@ -131,9 +135,15 @@ public TemplateEngine(IEnumerable<string> templates, IDictionary<string, string>
131135
132136 foreach ( var a in templateArguments )
133137 {
134- this . engine . RegisterTemplate ( a . Key , a . Value ) ;
138+ this . RegisterTemplate ( a . Key , a . Value ) ;
135139 }
136140 }
141+ List < string > registerTemplates = new List < string > ( ) ;
142+ private void RegisterTemplate ( string templateName , string template )
143+ {
144+ registerTemplates . Add ( template ) ;
145+ this . engine . RegisterTemplate ( templateName , template ) ;
146+ }
137147
138148
139149 private class NullEncoder : ITextEncoder
@@ -205,7 +215,7 @@ private void RegisterTemplate(StringBuilder sb, string currentTemplateName)
205215 }
206216 else
207217 {
208- this . engine . RegisterTemplate ( currentTemplateName , sb . ToString ( ) . TrimEnd ( ) ) ;
218+ this . RegisterTemplate ( currentTemplateName , sb . ToString ( ) . TrimEnd ( ) ) ;
209219 }
210220 sb . Clear ( ) ;
211221 }
0 commit comments