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.

sS tok_formatDollarVars(S pat, MapSO vars) {
  if (empty(vars)) ret pat;
  MapSO vars2 = mapKeys addDollarPrefix(vars);
  ifdef tok_formatDollarVars_debug
    printVars tok_formatDollarVars(+pat, +vars, +vars2);
  endifdef
  LS tok = javaTok(pat);
  for (int i = 1; i < l(tok); i += 2) {
    S var = tok.get(i);
    if (!isIdentifier(var)) continue;
    S value = strOrNull(vars2.get(var));
    if (value != null) tok.set(i, value);
  }
  S output = join(tok);
  ifdef tok_formatDollarVars_debug
    printVars tok_formatDollarVars(+output);
  endifdef
  ret output;
}

sS tok_formatDollarVars(S pat, O... _) {
  ret tok_formatDollarVars(pat, paramsToMap(_));
}

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: 22 / 52
Version history: 8 change(s)
Referenced in: [show references]