Enhanced syntax for NEON hashes

Notice: This thread is very old.

6 years ago

David Grudl
Nette Core | 6989
+
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

6 years ago

Vojtěch Dobeš
Member | 1318
+
0
-

Sir, you read my mind before I read it.

6 years ago

Tomáš Votruba
Moderator | 1154
+
0
-

Comes really handy.

6 years ago

mkoubik
Generous Backer | 731
+
0
-

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

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

?

6 years ago

Tomáš Votruba
Moderator | 1154
+
0
-

@mkoubik: I guess this would remain the same.

6 years ago

Filip Procházka
Moderator | 4693
+
0
-

I would love this syntax

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

6 years ago

Vojtěch Dobeš
Member | 1318
+
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)

6 years ago

David Matějka
Moderator | 6109
+
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]

6 years ago

Vojtěch Dobeš
Member | 1318
+
0
-

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

6 years ago

hrach
Member | 1816
+
0
-

+1

6 years ago

Pavel Macháň
Member | 283
+
0
-

+1

I hate this empty line

-
  item:

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

6 years ago

David Grudl
Nette Core | 6989
+
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