@@ -161,6 +161,49 @@ describe('Twig.js Include ->', function () {
161
161
rethrow : true
162
162
} ) ;
163
163
} ) ;
164
+
165
+ it ( 'should include paths with trailing or leading whitespace' , function ( ) {
166
+ twig ( {
167
+ 'data' : 'path has leading whitespace' ,
168
+ 'id' : ' path/with/leading/whitespace.twig' ,
169
+ } ) ;
170
+ twig ( {
171
+ 'data' : 'path has trailing whitespace' ,
172
+ 'id' : 'path/with/trailing/whitespace.twig ' ,
173
+ } ) ;
174
+
175
+ twig ( {
176
+ 'allowInlineIncludes' : true ,
177
+ 'data' : "{% include ' path/with/leading/whitespace.twig' %} - {% include 'path/with/trailing/whitespace.twig ' %}" ,
178
+ } ) . render ( ) . trim ( ) . should . equal ( 'path has leading whitespace - path has trailing whitespace' ) ;
179
+ } ) ;
180
+
181
+ it ( 'should not include paths without trailing or leading whitespace' , function ( ) {
182
+ twig ( {
183
+ 'data' : 'path has no leading whitespace' ,
184
+ 'id' : 'path/without/leading/whitespace.twig' ,
185
+ } ) ;
186
+ twig ( {
187
+ 'data' : 'path has no trailing whitespace' ,
188
+ 'id' : 'path/without/trailing/whitespace.twig' ,
189
+ } ) ;
190
+
191
+ ( function ( ) {
192
+ twig ( {
193
+ 'allowInlineIncludes' : true ,
194
+ 'data' : "{% include ' path/without/leading/whitespace.twig' %}" ,
195
+ 'rethrow' : true ,
196
+ } ) . render ( ) ;
197
+ } ) . should . throw ( / U n a b l e t o f i n d t e m p l a t e f i l e / ) ;
198
+
199
+ ( function ( ) {
200
+ twig ( {
201
+ 'allowInlineIncludes' : true ,
202
+ 'data' : "{% include 'path/without/trailing/whitespace.twig ' %}" ,
203
+ 'rethrow' : true ,
204
+ } ) . render ( ) ;
205
+ } ) . should . throw ( / U n a b l e t o f i n d t e m p l a t e f i l e / ) ;
206
+ } ) ;
164
207
} ) ;
165
208
166
209
describe ( 'Twig.js Extends ->' , function ( ) {
@@ -193,4 +236,4 @@ describe('Twig.js Extends ->', function () {
193
236
const output = template . render ( ) ;
194
237
output . trim ( ) . should . equal ( 'Nothing to see here' ) ;
195
238
} ) ;
196
- } ) ;
239
+ } ) ;
0 commit comments