Last active
December 21, 2015 04:29
-
-
Save splinter/6249520 to your computer and use it in GitHub Desktop.
Basic usage of the snoop helper
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
var context={ | |
fruits:[ | |
{ | |
name:'apples', | |
label:'I like salted apples', | |
value:'1', | |
info:{ | |
some_data:'Have some more apples!' | |
} | |
}, | |
{ | |
name:'oranges', | |
label:'I don't like oranges', | |
value:'2' | |
}, | |
{ | |
name:'tomatoes', | |
label:'Tomatoes are yummy!', | |
value:'3' | |
} | |
] | |
} | |
Basic Usage: | |
{{{ snoop "fruits(name=apples).value" context }}} = 1 | |
{{{ snoop "fruits(name=oranges).label" context }}} = I don't like oranges | |
{{{ snoop "fruits(name=apples).info.some_data" context }}} = Have some more apples | |
{{{ snoop "fruits(value=3).name" context }}} = tomatoes | |
Invalid path expressions will return an empty string "" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment