mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
[FIX] strtabs interpolation in nimscript (#15172)
* [FIX] strtabs interpolation in nimscript * [TEST] Use `static` in strtabs test
This commit is contained in:
@@ -302,7 +302,7 @@ proc getValue(t: StringTableRef, flags: set[FormatFlag], key: string): string =
|
||||
when defined(js) or defined(nimscript):
|
||||
result = ""
|
||||
else:
|
||||
if useEnvironment in flags: result = os.getEnv(key).string
|
||||
if useEnvironment in flags: result = getEnv(key).string
|
||||
else: result = ""
|
||||
if result.len == 0:
|
||||
if useKey in flags: result = '$' & key
|
||||
|
||||
5
tests/stdlib/tstrtabs.nims
Normal file
5
tests/stdlib/tstrtabs.nims
Normal file
@@ -0,0 +1,5 @@
|
||||
import strtabs
|
||||
|
||||
static:
|
||||
let t = {"name": "John", "city": "Monaco"}.newStringTable
|
||||
doAssert "${name} lives in ${city}" % t == "John lives in Monaco"
|
||||
Reference in New Issue
Block a user