From 486c8a8e1d0f279c7dbc066a541443f2564792a2 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sun, 19 Apr 2015 13:15:21 -0400 Subject: [PATCH] remove hidden items --- ex.moon | 4 +--- main.go | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ex.moon b/ex.moon index 7acb064..2d11bc2 100644 --- a/ex.moon +++ b/ex.moon @@ -30,10 +30,8 @@ other_hash: { key_4: ["five" 6 7.8] } -item_one: "this is item one" - # we may reference an item that was defined earlier -item_two: item_one +repeat_hash: hash # items can be hidden. i.e., they're only valid in the parse and eval stage as # intermediate values internal to the config file; they are *not* visible to diff --git a/main.go b/main.go index e5fba19..9810eef 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "os" + "strings" ) func input(n int) io.ReadCloser { @@ -63,6 +64,11 @@ func eval(r io.Reader) (map[string]interface{}, error) { if _, err := n.eval(ctx); err != nil { return nil, fmt.Errorf("eval error: %s\n", err) } + for name, _ := range ctx { + if strings.HasPrefix(name, ".") { + delete(ctx, name) + } + } return ctx, nil }