From 03c5f5eb74ae0c1ae190e01d6a0f4428ead23ec1 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 31 May 2024 10:00:53 +0200 Subject: [PATCH] helpers/toLuaObject: add support for raw keys --- lib/to-lua.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/to-lua.nix b/lib/to-lua.nix index c4244bd3..87d3340f 100644 --- a/lib/to-lua.nix +++ b/lib/to-lua.nix @@ -15,12 +15,17 @@ rec { + (concatStringsSep "," ( mapAttrsToList ( n: v: - if (builtins.match "__unkeyed.*" n) != null then - toLuaObject v + let + valueString = toLuaObject v; + in + if hasPrefix "__unkeyed" n then + valueString + else if hasPrefix "__rawKey__" n then + "[${n}] = " + valueString else if n == "__emptyString" then - "[''] = " + (toLuaObject v) + "[''] = " + valueString else - "[${toLuaObject n}] = " + (toLuaObject v) + "[${toLuaObject n}] = " + valueString ) (filterAttrs (n: v: v != null && (toLuaObject v != "{}")) args) )) + "}"