Skip to content

Instantly share code, notes, and snippets.

@leafo
Created December 13, 2013 15:36
Show Gist options
  • Save leafo/7946062 to your computer and use it in GitHub Desktop.
Save leafo/7946062 to your computer and use it in GitHub Desktop.
using other data sources in lapis config
import config from require "lapis.config"
json_file = (fname) ->
json = require "cjson"
file = assert io.open fname
with json.decode file\read "*a"
file\close!
config {"production", "development"}, ->
-- this is the same set syntax normally used, so the left hand function can
-- be any name
my_json_config json_file "my_json_config.json"
--
-- my_json_config.json:
-- {
-- "value": "yes",
-- "color": 123,
-- "thing": [3,2,1]
-- }
c = require("lapis.config").get "development"
print c.my_json_config.thing[1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment