Skip to content

Commit

Permalink
fix(yaml format): Fix parsing dropdowns where the variable name is 'c…
Browse files Browse the repository at this point in the history
…hart'
  • Loading branch information
kantord committed Mar 13, 2018
1 parent b157192 commit 14ec305
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/yaml-format/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ const rules = [
'component': 'columns',
'data': value.map(parser)
})],
[[/dropdown ([^=]+)=(.*)/], (match, value) => ({
'component': 'dropdown',
'args': {'variable': match[1], 'default': match[2]},
'data': value
})],
[[/(stacked)? *([a-z]+) (chart|plot|diagram|graph)/], (match, value) => ({
'component': 'chart',
'args': {
Expand All @@ -32,11 +37,6 @@ const rules = [
},
'data': value
})],
[[/dropdown ([^=]+)=(.*)/], (match, value) => ({
'component': 'dropdown',
'args': {'variable': match[1], 'default': match[2]},
'data': value
})]
]

const handle_urls = (component) => {
Expand Down
8 changes: 8 additions & 0 deletions src/yaml-format/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,14 @@ describe('yaml format - dropdown component', function() {
'data': 42
}
},
{
'input': {'dropdown chart=pie': 42},
'output': {
'component': 'dropdown',
'args': {'variable': 'chart', 'default': 'pie'},
'data': 42
}
},
]


Expand Down

0 comments on commit 14ec305

Please sign in to comment.