It seems like actions should be declared as
- pattern: foo
rather than
- pattern
- value: foo
in YAML. I realize there's consistency with the XML parse output this way, but (if that's the reason) it seems like it might be better to write that structure into the processing of prettier YAML.
Comments
Comment #1
michaek commentedI should have previewed that before posting, because I meant
in the second code block.
Comment #2
sarvab commentedI'll take a closer look at this when I have the chance, but it may not be very simple to do.
YAML parsing is being done by an external library, so we have less control over the final outcome as we would have with XML, but here is a possible issue as I see it (I'm coming from an XML point of view here really since I'm not too familialr with the YAML yet) with that type of syntax:
pattern: foo
content:
name: page
pattern: bar
The resulting object would be:
array(
'pattern' => array(foo, bar),
'content' => array('name' => 'page')
)
Which means we would have lost the order of the actions.
However, I'm definitely up for suggestions and solutions to make that work :)
Comment #3
michaek commentedThat's interesting (and a good reason for keeping it the way it is!). I'll take a closer look.
Comment #4
michaek commentedLooks like you're right! I'm marking this "by design".
Comment #5
ChrisBryant commentedThis is definitely a great point and early on a lot of work went into keeping the syntax as simple and clean as possible. Since then as more features have been added, and more importantly, more thorough testing done that's shown the need to change the syntax in some places which has resulted in it not being quite as simple and pretty.
Let's keep reviewing the syntax to make sure that it's always as simple and straightforward as possible.
Thanks!
Comment #6
vaish commentedIt would actually be possible to implement the change requested in this issue without a great difficulty and I almost went ahead and did it. What stopped me is when I looked at the YAML file as a whole and noticed how that would make our YAML file syntax inconsistent.
This change would be possible only for actions that can be represented in XML as value which boils down to patterns, theme and modules. All other actions would need to preserve current YAML syntax due to the limitations with external YAML library (see the explanation below).
This would lead to inconsistent syntax where we would have something like this:
I find it preferable to be consistent and use the same syntax for all the actions. At the same time I'm open to changing the syntax if some convincing arguments are provided in support of that.
* If we would try to emulate XML syntax in YAML and have something like this:
YAML parser would produce associative array with action names used as array keys. This would create two problems: order of actions would be lost and array wouldn't be able to store more then one action of each type - each subsequent action would overwrite previous one (due to the array keys being action names).