Skip to content

Instantly share code, notes, and snippets.

@mctep
Last active December 14, 2015 20:19
Show Gist options
  • Save mctep/5143075 to your computer and use it in GitHub Desktop.
Save mctep/5143075 to your computer and use it in GitHub Desktop.
// data: { foo: { bar: { name: 'bar' } } }
match / {
apply .foo content
}
match .foo content {
mustBeConst = { bar: { name: 'new bar' } }
// клеим в foo новый bar
// получается { foo: { bar: [ { name: 'bar' }, { name: 'new bar' }] } }
apply mustBeConst.bar content
// o_O
if (mustBeConst.bar.prop) {
"mustBeConst not a constant"
}
}
match .bar content {
myVar = { prop: 'ooh!' }
// клеим в каждый .bar новое .prop
// получается { foo: { bar: [ { name: 'bar', prop: 'ooh!' }, { name: 'new bar', prop: 'ooh!'}] } }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment