Created
December 13, 2013 15:36
-
-
Save leafo/7946062 to your computer and use it in GitHub Desktop.
using other data sources in lapis config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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