08.
Mistakes and Macros
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
4 Comments
Situation:
I'am using a twig macro, like in this tutorial.
It gets called twice in the .twig file, with the same arguments.
(Because the same element gets generated for a responsive "mobile" view and for the "normal" desktop browser view)
Question:
Is there any way to optimize this?
Because the macro needs some time to get executed and both calls to it are 100% identical.
But I can't find a "copy a executed macro content" type function.
Maybe the solution is to set/define a variable with the content that gets generated and call this variable twice?
What would you?
Hey Mike P.
I wouldn't care until it becomes a real performance problem. If it already is, then you have to consider a couple of options. In your case, storing the output in a variable seems like a good choice because caching it would increase complexity.
Cheers!
unable to finish coding challange due to error on access-control-allow-origin!
Hey Mark,
We're sorry about that! We had a bug which affected some challenges. Most probably it was due to jQuery upgrade. But now it's fixed. If you still have this issue with some challenges - let us know.
Cheers!
"Houston: no signs of life"
Start the conversation!