question: public String convertTemplate ( String template ) { String contents = StringUtils . fileContentsToString ( template ) ; if ( ! contents . endsWith ( "\n" ) ) { contents += "\n" ; } Perl5Util perl = new Perl5Util ( ) ; for ( int i = 0 ; i < perLineREs . length ; i += 2 ) { contents = perl . substitute ( makeSubstRE ( i ) , contents ) ; } if ( perl . match ( "m/javascript/i" , contents ) ) { contents = perl . substitute ( "s/\n}/\n#end/g" , contents ) ; } else { contents = perl . substitute ( "s/(\n\\s*)}/$1#end/g" , contents ) ; contents = perl . substitute ( "s/#end\\s*\n\\s*#else/#else/g" , contents ) ; } return contents ; }
target:  Apply find/replace regexes to our WM template