Fluid icon indicating copy to clipboard operation
Fluid copied to clipboard

[TASK] Allow escaping of characters inside accessor paths

Open mneuhaus opened this issue 10 years ago • 2 comments

currently it's not possible to access keys of arrays that contain fluid specific characters like . { } etc. although that's not a usecase that we "endorse" using those characters inside accessor paths, but there's a relatively valid usecase to use a "." inside the array key when you assign typoscript values into fluid which contains dots for the array keys

example*

<?php
$view->assign('foo', 
    'foo' => array(
        'bar.' => 'dasoidjo'
    )
);
{foo.bar\.}

mneuhaus avatar Nov 08 '15 09:11 mneuhaus

if you can make the getPropertyPath method split on only un-escaped dots it should work

mneuhaus avatar Jan 03 '16 21:01 mneuhaus

This would be awesome, how is the status on this ?

micron avatar May 03 '17 09:05 micron

Hey.

My assessment after dealing with StandardVariableProvider and it's friends for a while: I don't think we should strive to support this anytime soon.

Claus had a PR on this with https://github.com/TYPO3/Fluid/pull/425, but I don't think this is the way to go since it increases complexity quite a bit and has a significant negative impact on performance: The variable provider construct is one of the most heavily used constructs at runtime within Fluid, we should strive for further streamlining and simplification instead.

As such, I'll close the PR for now, and will look into more options to further improve perfomance in this area with additional patches - I think there is still quite some potential if we pre-optimize lookups in compiled templates for instance, by providing some more specialized (quicker) methods for cases that can be sorted out at compile-time (eg. splitting by array early and see if there are sub references at all in the dotted variable string).

I'd say, performance has a higher priority than having variable names that include dots and curly braces, since those can be avoided relatively easily in most cases. As such, I'll close this issue for now.

lolli42 avatar May 04 '23 23:05 lolli42