File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ export function assignFilters(config, metalsmith) {
5151 }
5252 return `//cdn.shopify.com/s/files/1/0354/1849/t/2/assets/${ asset_url } ` ;
5353 } ,
54+ modulo : function ( a , b ) {
55+ return a % b ;
56+ } ,
5457 img_tag : function ( str , alt ) {
5558 console . log ( str , args ) ;
5659 return `<img src="${ str } " alt="alternate text" class="${ args } " />` ;
Original file line number Diff line number Diff line change @@ -134,6 +134,31 @@ describe('URL Filters', () => {
134134 . build ( done ) ;
135135 } ) ;
136136
137+ it ( 'should have modulo filter' , ( done ) => {
138+
139+ let filters ;
140+ m . use ( ( files , metalsmith , next ) => {
141+
142+ let localePath = path . resolve ( 'test/fixtures/locales' ) ;
143+ filters = assignFilters ( {
144+ locale : 'en.default.obj' ,
145+ localePath
146+ } , metalsmith ) ;
147+
148+ expect ( filters . modulo ) . to . be . ok ;
149+ let data = filters . modulo ( 4 , 2 ) ;
150+ expect ( data ) . to . equal ( 0 ) ;
151+
152+ next ( ) ;
153+ } )
154+ . use ( layouts ( {
155+ engine : 'liquid' ,
156+ directory : 'templates'
157+ } ) )
158+ . build ( done ) ;
159+
160+ } ) ;
161+
137162 xit ( 'should have img_tag filter' , ( done ) => {
138163
139164 let str = 'red_shirt_small.jpg' ;
You can’t perform that action at this time.
0 commit comments