Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Možnost escapovat tečku v cestě v config.neon #1247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ondrej-tuhacek
Copy link

Možnost v config.neon v %odkazu% escapovat tečku druhou tečkou, pokud jsou po cestě klíče obsahující tečku.

common:
    parameters:
        parametr.prvni:
            klic1: 'hodnota'
            klic2: 12
        parametr.druhy:
            klic1: %parameters.parametr..prvni.klic1%
            klic2: %parameters.parametr..prvni.klic2%
...

@enumag
Copy link
Contributor

enumag commented Sep 24, 2013

What's wrong with this?

common:
    parameters:
        parametr:
            prvni:
                klic1: 'hodnota'
                klic2: 12
            druhy:
                klic1: %parameters.parametr.prvni.klic1%
                klic2: %parameters.parametr.prvni.klic2%

@fprochazka
Copy link
Contributor

Do not use dots but underscores %parameters.parametr_prvni.klic1%
or camelCase %parameters.parametrPrvni.klic1%

@ondrej-tuhacek
Copy link
Author

Basically nothing, but that creates another configuration structure. Sometimes you might for some reason want to have periods in configuration keys. And since there is this possibility, there could be also possibility to address these keys with %references%.

@milo
Copy link
Member

milo commented Sep 24, 2013

If so, %parameters."parametr.prvni".klic1% seems better to me.

@@ -63,7 +63,9 @@ public static function expand($var, array $params, $recursive = FALSE)
throw new Nette\InvalidArgumentException('Circular reference detected for variables: ' . implode(', ', array_keys($recursive)) . '.');

} else {
$val = Nette\Utils\Arrays::get($params, explode('.', $part));
$partSplit = preg_split('#(?<!\.)\.(?!\.)#i', $part);
array_walk($partSplit, function(&$segment) { $segment = preg_replace('#\.{2}#i', '.', $segment); });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array_map is better.

@mishak87
Copy link
Contributor

Wouldn't be better instead of escaping dots that separate numbers use array indexes?
%parameters.parameter.0.key% makes more sense to me. But it looks more like you need inheritance (or default values).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants