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
Allow arrays (Hash::flatten'ed) to be used in substitutions #6956
Conversation
I also wanted to be able to use template vars with |
So maybe just allow all valid variable names? |
@hmic Having a test for this would be great. |
@markstory I never said my wants were valid 😛 |
So which way to go?
|
Replacement data is provided as associative array with keys used as template variable name. So I guess any valid array key should be allowed. |
So this is about everything (integer or (cast to) string), except arrays or objects... On one hand I like the idea and it would be the "correct" solution as you said, on the other hand it's kind of... hmm... |
Not sure what you mean :) |
I think accepting any valid array key (which is pretty much anything) will have some problems as }} is totally legal in an array key. Sticking with simpler word characters and . will solve the current problem and let us expand functionality in the future as well. |
ae5cd3c
to
d3a99dc
Compare
I agree with @markstory. Lets keep it simple world list with dot and dash :troll:. |
Thats what my last commit does, characters, numbers, space and .-_ But as I amended mylast one, I think travis did not fetch the new commit :-( Should I remove space, numbers and _ and push again or is this sane enough? |
@hmic Travis will fetch whatever you push to your branch. If you amended your last commit instead of making a new one you will have to force push your branch to github. |
Tests still needed, though. |
427212a
to
f39a440
Compare
I wouldn't include |
😿 |
In my oppinion it's far more usefull to be able to (at least) use flattened array data than doing math operations (in the future). On the other hand, it would be easy to allow other oparations on the substitutions with extra substitution classes like [[ ]] for math: [[ {{entity.my-var}} - {{any_other thing}} ]] If thats a too big deal, revert to only additionally allow for the dot like proposed originally? |
@hmic Lets add |
Numbers are considered ok too? Maybe _? I really like to be able to use fields of my database tables from flattened arrays... |
E.g. arrays (Hash::flatten'ed) to be used in substitutions. This allows for the standard . notation of arrays to be used within substitions like attendee.fistname and event.name from e.g. Hash::flatten($entity->toArray());
Thanks @hmic ! |
Allow arrays (Hash::flatten'ed) to be used in substitutions
Looks great now. |
This allows for the standard . notation of arrays to be used within substitions like
attendee.fistname and event.name from e.g. Hash::flatten($entity->toArray());
As the . notation is used in many places, this would make sense here too.