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

michaek’s picture

I should have previewed that before posting, because I meant

 - tag: pattern
      - value: foo

in the second code block.

sarvab’s picture

I'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 :)

michaek’s picture

That's interesting (and a good reason for keeping it the way it is!). I'll take a closer look.

michaek’s picture

Status: Active » Closed (works as designed)

Looks like you're right! I'm marking this "by design".

ChrisBryant’s picture

This 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!

vaish’s picture

It 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:

  - tag: content
      name: Article
      type: article
      comment: 0
      status: 1
  - theme: garland
  - tag: field
      type: article
      name: summary
      label: Article Summary
      option: text
      widget: text_textarea
      rows: 3
      text_processing: 1
      weight: -1
  - pattern: news
  - tag: vocabulary
      name: Article Keywords
      nodes:
        article: article
      tags: 1

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:

  - content:
      name: Article
      type: article
      comment: 0
      status: 1
  - theme: garland
  - vocabulary:
      name: Article Keywords
      nodes:
        article: article
      tags: 1

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).