private static String translateVar ( SoyToJsVariableMappings variableMappings , Matcher matcher ) { Preconditions . checkArgument ( matcher . matches ( ) ) ; String firstPart = matcher . group ( 1 ) ; StringBuilder exprTextSb = new StringBuilder ( ) ; // ------ Translate the first key, which may be a variable or a data key ------ String translation = getLocalVarTranslation ( firstPart , variableMappings ) ; if ( translation != null ) { // Case 1: In-scope local var. exprTextSb . append ( translation ) ; } else { // Case 2: Data reference. exprTextSb . append ( "opt_data." ) . append ( firstPart ) ; } return exprTextSb . toString ( ) ; }
Helper function to translate a variable or data reference .