diff --git a/guides/working-with-lua.livemd b/guides/working-with-lua.livemd index 52fa061..8bf90e1 100644 --- a/guides/working-with-lua.livemd +++ b/guides/working-with-lua.livemd @@ -4,7 +4,7 @@ ```elixir Mix.install([ - {:lua, "~> 0.0.20"} + {:lua, "~> 0.0.21"} ]) ``` diff --git a/lib/lua/table.ex b/lib/lua/table.ex index b667f9d..e1acd0d 100644 --- a/lib/lua/table.ex +++ b/lib/lua/table.ex @@ -138,6 +138,7 @@ defmodule Lua.Table do defp format_value(key, value, formatter) do case formatter.(key, value) do list when is_list(list) -> "{#{print_table(list, formatter)}}" + map when is_map(map) -> "{#{print_table(map, formatter)}}" {:userdata, _value} -> inspect("") true -> "true" false -> "false" diff --git a/mix.exs b/mix.exs index c309b79..3012f32 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule Lua.MixProject do use Mix.Project @url "https://github.com/tv-labs/lua" - @version "0.0.20" + @version "0.0.21" def project do [ diff --git a/test/lua/table_test.exs b/test/lua/table_test.exs index 13bfd41..a431d60 100644 --- a/test/lua/table_test.exs +++ b/test/lua/table_test.exs @@ -58,6 +58,12 @@ defmodule Lua.TableTest do ~S<{a = 1, b = "~D[2024-09-22]"}> end + test "it can handle nested maps" do + table = [a: 1, b: 2, c: %{d: %{e: 5}}] + + assert Lua.Table.as_string(table) == "{a = 1, b = 2, c = {d = {e = 5}}}" + end + # We can't handle self-referential tables as # Luerl cannot decode them @tag :skip