Class SimpleSubstitutionMap

  • All Implemented Interfaces:
    SubstitutionMap

    public class SimpleSubstitutionMap
    extends java.lang.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.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String get​(java.lang.String key)
      Gets the string that should be substituted for key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SimpleSubstitutionMap

        public SimpleSubstitutionMap()
    • Method Detail

      • get

        public java.lang.String get​(java.lang.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:
        java.lang.IllegalArgumentException - if key is null