Enhanced syntax for NEON hashes

5 years ago

David Grudl
Nette Core | 6847
+
0
-

In Neon it is not possible to write this:

- item:
  - sub
  - sib

You have to do:

-
  item:
    - sub
    - sib

What is benefit? In config you can write:

services:
    - App\Helpers\LangResolver:
        - setup: ...
        - autowired: off

It would be nice if this will be possible too:

services:
    - App\Helpers\LangResolver(args, ...)
        - setup: ...
        - autowired: off

5 years ago

Vojtěch Dobeš
Member | 1317
+
0
-

Sir, you read my mind before I read it.

5 years ago

Tomáš Votruba
Moderator | 1154
+
0
-

Comes really handy.

5 years ago

mkoubik
Generous Backer | 734
+
0
-

Maybe I don't get it but what would be the new syntax for

people:
    -
        name: John
        age: 25
    -
        name: Jane
        age: 42

?

5 years ago

Tomáš Votruba
Moderator | 1154
+
0
-

@mkoubik: I guess this would remain the same.

5 years ago

Filip Procházka
Moderator | 4693
+
0
-

I would love this syntax

services:
    App\Helpers\LangResolver(args, ...):
        setup: ...
        autowired: off

5 years ago

Vojtěch Dobeš
Member | 1317
+
0
-

What I would personally love to see possible (my often usecase):

services:
    - App\Helpers\ILangResolverFactory
        create: class(%defaultLang%)
        parameters: [defaultLang]

class is magic placeholder for real name that the factory creates according to @return annotation. Using parameters for generated factories always ends in duplicating the @return annotation.

Last edited by vojtech.dobes (2014-02-13 14:12)

5 years ago

David Matějka
Moderator | 5846
+
0
-

@vojtech.dobes: Now you can set only arguments without class (create),

services:
    -
        implement: App\Helpers\ILangResolverFactory
        arguments: [%defaultLang%]
        parameters: [defaultLang]

So with this enhancement it will be only

services:
    - App\Helpers\ILangResolverFactory
        arguments: [%defaultLang%]
        parameters: [defaultLang]

5 years ago

Vojtěch Dobeš
Member | 1317
+
0
-

matej21 Yeah, I thought so but I was waiting for confirmation :). Great job!

5 years ago

hrach
Member | 1812
+
0
-

+1

5 years ago

Pavel Macháň
Member | 285
+
0
-

+1

I hate this empty line

-
  item:

Last edited by EIFEL (2014-02-14 00:19)

5 years ago

David Grudl
Nette Core | 6847
+
0
-

mkoubik wrote:

Maybe I don't get it but what would be the new syntax for..

This should be valid, but only for indentation using spaces :-(

people:
    - name: John
      age: 25
    - name: Jane
      age: 42