On Sun, Apr 11, 2010 at 10:56 AM, Stuart P. Bentley <stu...@testtrack4.com>wrote:
> Granted I don't know Cosmo, so I don't know if the functions have more > involved semantics, but the beauty of Lua is you can do something like this: > > functions = {"fill"} -- and every other function you need to escape with > > for _, name in pairs(functions) do > local original = cosmo[name] > cosmo[name] = function(...) > return original(string.gsub(...,"%$",%$%$")) > end > end Thanks. I tried your suggestion, but it gets in the way of other constructs. require "luarocks.require" require("cosmo", "current-1") functions = {"fill"} -- and every other function you need to escape with ---[[ for _, name in pairs(functions) do local original = cosmo[name] cosmo[name] = function(...) return original(string.gsub(...,"%$","%$%$")) end end --]] env = { hello_msg = "hi there" } print( cosmo.fill([[helo $("div").text("$hello_msg")]], env) ) gives this: hello $("div").text("$hello_msg") instead of the desired: hello $("div").text("hi there")
_______________________________________________ Kepler-Project mailing list Kepler-Project@lists.luaforge.net http://lists.luaforge.net/cgi-bin/mailman/listinfo/kepler-project http://www.keplerproject.org/