1
00:00:00,000 --> 00:00:10,466
Hi, In the earlier lecture we discussed about how to include a template within another template.

2
00:00:10,466 --> 00:00:13,432
Also, I mentioned about two ways of including the template.

3
00:00:13,433 --> 00:00:20,733
One is using the keyword template, another one using include. In the earlier example we saw using the keyword

4
00:00:20,733 --> 00:00:24,199
template. While discussing that, I mentioned an important point

5
00:00:24,200 --> 00:00:27,366
while including the template, the alignment doesn't matter.

6
00:00:27,366 --> 00:00:32,232
And within the template, whatever the alignment provided that will be taken as it is.

7
00:00:32,232 --> 00:00:36,433
Now, let me get into the template where I have defined the details. Here

8
00:00:36,433 --> 00:00:39,033
I have provided the alignments. With the same alignments

9
00:00:39,033 --> 00:00:46,699
It will get included and it's quite difficult to identify or assume where it is going to get included

10
00:00:46,700 --> 00:00:48,100
And at what indentations

11
00:00:48,100 --> 00:00:55,866
See, for example, I might use this particular label in different yaml files and in different yaml files

12
00:00:55,866 --> 00:00:58,066
Different type of indentation might be used.

13
00:00:58,066 --> 00:01:05,199
And having different files for different indentation is going to be a difficult and hard task.

14
00:01:05,200 --> 00:01:11,200
That's where another type of template include methodology is introduced that is using the keyword include.

15
00:01:11,200 --> 00:01:18,133
Now let's do the same demo using the template and how to overcome that using the include keyword.

16
00:01:18,133 --> 00:01:21,799
Let me get into the demo. As a part of the helper

17
00:01:21,800 --> 00:01:25,100
I'm going to introduce another template definition.

18
00:01:25,100 --> 00:01:31,733
I'm providing the name mychart.version, assume I do not have any alignments.

19
00:01:31,733 --> 00:01:38,099
Now I'm going to include this particular template using the keyword template.

20
00:01:38,100 --> 00:01:43,333
So template mychart.version I'm including.

21
00:01:43,333 --> 00:01:48,833
Now, let me go ahead and do a dry run and check how it's working.

22
00:01:48,833 --> 00:01:52,999
Let me run the dry run. It's going to give the passing error.

23
00:01:53,000 --> 00:01:57,100
The reason because it doesn't get indented properly.

24
00:01:57,100 --> 00:02:00,966
I can overcome this particular problem by using include.

25
00:02:00,966 --> 00:02:07,699
Let me go ahead and edit the template file.

26
00:02:07,700 --> 00:02:11,766
here I'm going to use include.

27
00:02:11,766 --> 00:02:18,299
Include provides additional option of mentioning how much indentation I wanted for this particular template.

28
00:02:18,300 --> 00:02:25,300
In this particular template, I included the lines for the labels and that needs to come after
four spaces.

29
00:02:25,300 --> 00:02:30,700
So indent I will mention four that will be done using the pipeline and here

30
00:02:30,700 --> 00:02:37,900
I'm going to mention the keyword include and name of the template to include and dot to pass the current scope.

31
00:02:37,900 --> 00:02:43,000
Then pipe and how much amount of indent I wanted. For even better understanding

32
00:02:43,000 --> 00:02:47,666
Let me go ahead and include the same thing over here along with the data.

33
00:02:47,666 --> 00:02:54,632
In case if I wanted that to get listed along with the data, then the indent should be of two spaces.

34
00:02:54,633 --> 00:02:59,866
Here I can mention same thing with indent as two. Now for better understanding

35
00:02:59,866 --> 00:03:04,599
lets see the content within the template definition. Here

36
00:03:04,600 --> 00:03:07,866
I do have two lines appname and appversion.

37
00:03:07,866 --> 00:03:14,199
And when it is getting included as a part of the labels, the indent will be four spaces along with the data.

38
00:03:14,200 --> 00:03:20,900
The indent will be two spaces. Let me go ahead and do a dry run.

39
00:03:20,900 --> 00:03:29,000
yes, It's generated properly here the appname and appversion got included with four space because label

40
00:03:29,000 --> 00:03:36,933
demands four spaces and along with the data, it got included with two spaces and always it is recommended

41
00:03:36,933 --> 00:03:42,599
to use include because it will have more control as well as it facilitates the reusability.

42
00:03:42,600 --> 00:03:48,333
This is for the reusability when I mean, in some places I may wanted that with four indent.

43
00:03:48,333 --> 00:03:52,033
And in some places I may wanted that with two indent.

44
00:03:52,033 --> 00:03:54,233
So as per the requirement I can configure

45
00:03:54,233 --> 00:03:59,133
But if I use the template that's going to be a difficult task.

46
00:03:59,133 --> 00:04:04,599
In a quick summary we have seen the different type of keywords to use to include the templates that

47
00:04:04,600 --> 00:04:08,566
is include and template keyword and what are all the differences

48
00:04:08,566 --> 00:04:13,566
And which one is better and how include keyword is much better than template

49
00:04:13,566 --> 00:04:16,132
keyword while including the templates.

