-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Enabling the use of looping (for in ..) into Template.php #9401
Conversation
This update enable the use of loop into template files. Allowing the user iterate through collections
removing unused variables
What would the output of this look like? Is it possible to utilize an inline-template call within the loop to customize the display of items? |
$delimiter = $construction[2]; | ||
$loop_text_to_replace = $construction[3]; | ||
|
||
if (is_array($objectArrayData) || $objectArrayData instanceof Varien_Data_Collection) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should allow more than arrays and object collections in here.
You should use is_array($data) || ($data instanceof Traversable)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied :)
Ah, yes - |
removing m1 variables type and renaming m1 methods
@bap14 Lets suppose that you have the following template: Increment ID: {{var order.increment_id}}
The output would be:
` |
@adragus-inviqa I have fixed that. Sorry! M1 is still running in my brain hehe |
Hi guys, I see a lot of thumbs up here which means Community is really in need of such functionality, but... Do you really think it's a good idea to expand some custom templating language? For example, Twig is a pretty mature technology, has pretty similar syntax and There is even some attempt https://github.com/kalenjordan/magento-twigmail to introduce Twig support in email templates for Magento 1 :) |
@orlangur I would say so but, I do know how much effort will be needed. At least my PR does not affect the actual M2 behaviour. :) |
Hi @thiagolima-bm Thanks |
@ishakhsuvarov Hey, I would like to continue. You can come up with the list ASAP |
Hi @thiagolima-bm do you have any progress on that or should we close this PR? |
Enabling use of arrays or collections.
@okorshenko Yes. The use of arrays is available too. |
@ishakhsuvarov Updated. |
@thiagolima-bm, thanks for considering Twig 👍 I don't think it would require too much efforts but will not insist until I have some proof-of-concept in my hand :) Sorry for not answering for a long time, I had something to say but somehow lost this thread and then forgot. What do you think about making your implementation more Twig-like instead of custom syntax? So, instead of
I think it would be better to partially implement capabilities of https://twig.sensiolabs.org/doc/2.x/tags/for.html
I think it's enough to implement subset of Twig features consisting of Also, would be really nice to place sample syntax in Please share your thoughts. |
` Increment ID: {{var order.increment_id}}
The output would be: Increment ID: 000000001
` |
adding Twig-like syntax
@ishakhsuvarov @orlangur @okorshenko The changes were made. |
@orlangur I do not know what is happening, but when I run these tests in my machice, everything works fine. Integration tests works fine. |
|
This reverts commit 9111eb5.
Thanks, @orlangur! All set. |
Hi @thiagolima-bm could you please look at failed static tests? |
Fixed on our side |
Ok! |
…php #9401 - reverted code shuffling
…php #9401 - fixed code style
…php #9401 - fixed code style
…php #9401 - fixed code style
…php #9401 - Updated test to support PHPUnit 6
@okorshenko somehow, my contributor label is missing :( |
Hi @thiagolima-bm, as we already discussed in scope of another PR, this is not something Magento can handle on its side. Please make sure all emails used for commits: https://github.com/magento/magento2/pull/9401/commits are associated with your current account. |
This update enable the use of loop into template files, allowing the user iterate through collections
Why do I think that this change is important?
This way would be more easy to create dynamic feed/exportation files as: xml, csv and so on.
Manual testing scenarios
// you may also use arrays
/*
$_things = [
['name' => 'Richard', 'age' => 24],
['name' => 'Jane', 'age' => 12],
['name' => 'Spot', 'age' => 7],
];
*/
Output: