Class SimpleSubstitutionMap

java.lang.Object
com.google.common.css.SimpleSubstitutionMap
All Implemented Interfaces:
SubstitutionMap

public class SimpleSubstitutionMap extends Object implements SubstitutionMap
A SubstitutionMap that trivially renames its CSS classes by adding an underscore. This may be helpful in debugging because it makes it easy to match the renamed value with the original while helping catch bugs where the CSS class name is hardcoded in the code. Example in Soy:
 // Case I: Hardcoded name (incorrect)
 <div class="CSS_MENU_BAR"></div>

 // Case II: Name used as variable (correct)
 <div class="{css CSS_MENU_BAR}"></div>
 

In Case I, the div would not get the effects of the CSS class when it is renamed, so hopefully the missing styles would help discover the source of the error.

  • Constructor Details

    • SimpleSubstitutionMap

      public SimpleSubstitutionMap()
  • Method Details

    • get

      public String get(String key)
      Gets the string that should be substituted for key. The same value must be consistently returned for any particular key, and the returned value must not be returned for any other key value.
      Specified by:
      get in interface SubstitutionMap
      Parameters:
      key - the text to be replaced (never null)
      Returns:
      the value to substitute for key
      Throws:
      IllegalArgumentException - if key is null