1
00:00:00,000 --> 00:00:12,433
Hi, Let us understand about looping. Like every other language, go template language also provides looping

2
00:00:12,433 --> 00:00:18,233
using range and the syntax is very similar to the other languages where

3
00:00:18,233 --> 00:00:22,599
I will be providing the values of collection to the range and within the block

4
00:00:22,600 --> 00:00:27,500
I can iterate over each and every element and pick the required values and do what

5
00:00:27,500 --> 00:00:29,866
ever the pipeline operation I wanted.

6
00:00:29,866 --> 00:00:33,766
I can do it within the block and the syntax is very simple.

7
00:00:33,766 --> 00:00:37,666
Let's go ahead and do a small demo and get better understanding.

8
00:00:37,666 --> 00:00:42,199
Let me go ahead and add a collection of values as a part of the values file.

9
00:00:42,200 --> 00:00:47,333
We get into the mychart within that I'm going to edit the values file.

10
00:00:47,333 --> 00:00:51,299
Here I'm going to add a key language used

11
00:00:51,300 --> 00:00:55,133
And within that I'm going to provide a collection of values.

12
00:00:55,133 --> 00:01:01,133
Now I'm going to read this specific key and a collection of values and iterate within the template

13
00:01:01,133 --> 00:01:06,199
Let me get into the template, edit the template, within the template

14
00:01:06,200 --> 00:01:08,000
I'm going to get the values.

15
00:01:08,000 --> 00:01:14,700
Let me delete the other lines so that we don't need to worry about the other information. As a part of the data

16
00:01:14,700 --> 00:01:22,433
I'm going to add the language used. So I will provide language used as a key, and within that I wanted to have

17
00:01:22,433 --> 00:01:29,299
a collection of values and here I do have the range and each and every element will be printed.

18
00:01:29,300 --> 00:01:33,600
So what I'm going to do, I'm going to get the lang used and their values.

19
00:01:33,600 --> 00:01:38,466
So I'll be getting collection of values and it will iterate depending on the number of elements within

20
00:01:38,466 --> 00:01:40,332
it. For each and every element

21
00:01:40,333 --> 00:01:46,933
I am going to get the current element, that is the scope within this particular block, and I'm going

22
00:01:46,933 --> 00:01:52,366
to convert that into a title format that is the first capital letter and put within the quote.

23
00:01:52,366 --> 00:01:57,732
So this is a very simple pipeline where I would convert that into a title and quote within it.

24
00:01:57,733 --> 00:02:03,499
And the block is getting over. We save the file and do a dry run.

25
00:02:03,500 --> 00:02:11,000
with this particular chart resources helm install dry run and provide the name of the release

26
00:02:11,000 --> 00:02:13,866
and the chart resources. Here

27
00:02:13,866 --> 00:02:18,666
It read the collection of values and it converted the first letter in to capital letter and put within

28
00:02:18,666 --> 00:02:24,899
the quote. So the main thing that we need to worry about is it read the collection of values

29
00:02:24,900 --> 00:02:31,100
And iterated depending on the number of elements within it and printed them as a part of the template.

30
00:02:31,100 --> 00:02:37,366
And this particular range, we can use it by other means as well, where I can read the individual element

31
00:02:37,366 --> 00:02:42,399
and assign it to a variable and access the variable within the block, that we will be seeing it as a

32
00:02:42,400 --> 00:02:44,500
part of the variable section.

33
00:02:44,500 --> 00:02:48,866
So in a quick summary we learnt about how to iterate over the collection using the range.

