From ff0d799cf0e5aaa23596cb27153738ce7add16ec Mon Sep 17 00:00:00 2001 From: alyx Date: Sat, 6 Apr 2024 18:18:35 -0400 Subject: Document lua, fix small theme bugs --- src/theming/lua.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/theming/lua.rs') diff --git a/src/theming/lua.rs b/src/theming/lua.rs index 0699f09..118762b 100644 --- a/src/theming/lua.rs +++ b/src/theming/lua.rs @@ -4,7 +4,7 @@ use std::path::Path; use std::fs; use std::sync::Mutex; -use mlua::{Lua, LuaSerdeExt, Compiler, StdLib, Value, LuaOptions, Table}; +use mlua::{Lua, LuaSerdeExt, Compiler, StdLib, Value, LuaOptions, Table, SerializeOptions}; use http::StatusCode; use crate::CONFIG; @@ -115,7 +115,12 @@ pub fn render_theme(name: &str, ctx: &crate::ctx::Ctx) -> Option { log::error!("Error loading `{name}`: {e}"); return Some(Err(StatusCode::INTERNAL_SERVER_ERROR)); }, //TODO: gate behind flag } - let ctx = match lua.to_value(ctx) { + let opts = SerializeOptions::new() + .serialize_none_to_null(false) + .serialize_unit_to_null(false) + .set_array_metatable(false); + + let ctx = match lua.to_value_with(ctx, opts) { Ok(ok) => ok, Err(e) => { log::error!("Lua context serialization error: {e}"); -- cgit v1.2.3-54-g00ecf