Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

23
LINES

< > BotCompany Repo | #1032962 // tok_formatDollarVars

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (4161L) is out of date.

1  
sS tok_formatDollarVars(S pat, MapSO vars) {
2  
  if (empty(vars)) ret pat;
3  
  MapSO vars2 = mapKeys addDollarPrefix(vars);
4  
  ifdef tok_formatDollarVars_debug
5  
    printVars tok_formatDollarVars(+pat, +vars, +vars2);
6  
  endifdef
7  
  LS tok = javaTok(pat);
8  
  for (int i = 1; i < l(tok); i += 2) {
9  
    S var = tok.get(i);
10  
    if (!isIdentifier(var)) continue;
11  
    S value = strOrNull(vars2.get(var));
12  
    if (value != null) tok.set(i, value);
13  
  }
14  
  S output = join(tok);
15  
  ifdef tok_formatDollarVars_debug
16  
    printVars tok_formatDollarVars(+output);
17  
  endifdef
18  
  ret output;
19  
}
20  
21  
sS tok_formatDollarVars(S pat, O... _) {
22  
  ret tok_formatDollarVars(pat, paramsToMap(_));
23  
}

Author comment

Began life as a copy of #1010857

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1032962
Snippet name: tok_formatDollarVars
Eternal ID of this version: #1032962/9
Text MD5: f04600ac746ade80249a5318badd8bbc
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-11 10:12:11
Source code size: 682 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 230 / 323
Version history: 8 change(s)
Referenced in: [show references]