private String replaceVariables ( final String css , final Map < String , String > variables ) { final StringBuffer sb = new StringBuffer ( ) ; final Matcher m = PATTERN_VARIABLE_HOLDER . matcher ( css ) ; while ( m . find ( ) ) { final String oldMatch = m . group ( ) ; final String variableName = m . group ( 1 ) ; final String variableValue = variables . get ( variableName ) ; if ( variableValue != null ) { final String newReplacement = oldMatch . replace ( oldMatch , variableValue ) ; m . appendReplacement ( sb , newReplacement . trim ( ) ) ; } else { LOG . warn ( "No variable with name " + variableName + " was found!" ) ; } } m . appendTail ( sb ) ; return sb . toString ( ) ; }
Replace variables from css with provided variables map .