All language subtitles for 007 Loops in Templates_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

Loops can be used to iterate over arrays are like objects in blade.

It's important to know loops in blade templates work the same as loops in PHP.

We will begin with that for each type of loop, as I think it would be the one you will most often use.

To work with realistic example, we will make use of their posts as a variable.

Our goal is to prepare a new page that will list old blog posts, titles.

First off, we need to move posts as variable out of this function.

We want to create a new route for displaying the lists of posts.

For this roots controller functions to have access to the post variable, now we add the use statements

after the function, the header inside the statement, you should list all variables that are not declared

inside the anonymous function.

So in our example, this is posts.

If you want or need to know more about anonymous functions in Puchi, go visit PPY documentation, page

the link you see on the screen on the resources.

Let's create a new route using the static jet method that you or I, we want our new page under is supposed

there are no arguments to disrupt.

It should render the Post's index template we are yet to create and the data pass to it is the Post's

right now.

To use this Post's variable, we actually have to add a used statement after the function header, the

same as we did previously.

At this point, I should mention that disarray can be generated using a shortcut in BHP.

Let me just paste it for you.

So if you called a BHP built in compact function, then it will produce an array where there will be

a key with the name exactly the same as the variable name and the value of the variable will be assigned

to that key.

So whenever you would like to be explicit and define the array or use the compact function is completely

up to you.

I prefer to be verbose, so I will stick to defining the full array.

You can read more about the compact function in the link.

Now, let's create the new template, The Post's index blade.

So essentially, this means creating an index blade profile file inside the posts folder to speed things

up.

We'll copy over the other template contents.

And just remove everything, what is inside the section content?

Now they're for each sentence is quite intuitive, first goes the array to iterate over, then they're

ASCII word and Furt is the variable name of the current element in the loop, the loop itself and swift

and for each directive.

Between the loop directives, we can now render the content of the current iteration variable, in our

case, it's an individual post.

So let's add a development and using their master syntax, let's output the post title now before we

go test it, we have to fix to the actual page title as we can't use the supposed variable outside the

scope of a loop.

It doesn't exist in here and this would cause an error.

So let's change it to just normal static text like blog posts and now save the changes and let's verify

it in the browser.

So the new URL should be just posts.

There it is.

We have the titles of our two blog posts.

As I've mentioned before, therefore, each directive works exactly the same as the for each loop.

So this means if you would also like to get the key of every element you iterate over and if we would

like to remind ourselves this array actually has keys explicitly specified, you can do that like you

would in which is you will specify another variable for the key and use the arrow.

Then we can output the key using mustache as well.

And maybe let's add a dot after it now, say the changes and let's see what this would output.

So there it is.

We can also get the keys this way.

So the summary now, there is more to learn about loops.

And in the next lecture's you will learn about other types of loops, how to stop the loop or skip elements.

We will also talk about a special loop variable, which has a lot of useful info about the loop itself,

like the current loop index.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.