youtube.pug
– Youtube videos and playlists ¶
View source code on GithubEmbed videos¶
mixin youtube-video(id)
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
- if ("autoplay" in attributes)
- autoplay = attributes.autoplay;
- delete attributes.autoplay;
- else
- autoplay = false;
- if (autoplay == true)
- autoplay = 1;
- else
- autoplay = 0;
- src = `https://www.youtube.com/embed/${id}?autoplay=${autoplay}`
iframe(src=`${src}`
frameborder="0"
allow="autoplay;encrypted-media"
allowfullscreen="true"
width="560"
height="315")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+youtube-video
(id)(autoplay=false, width="560", height="315")¶ Insert a Youtube video
iframe
given a identificator.Arguments: - id (string) – Video identificator, corresponds to some letters and numbers located at the end of a video url. For example, if a video has the url https://www.youtube.com/watch?v=xK1bZBzowF0, the identificator is
xK1bZBzowF0
. - autoplay (bool, optional) – If
true
, video will be inmediatly played after loaded.
- id (string) – Video identificator, corresponds to some letters and numbers located at the end of a video url. For example, if a video has the url https://www.youtube.com/watch?v=xK1bZBzowF0, the identificator is
Usage¶
Input
+youtube-video("xK1bZBzowF0")(width="100%")
Output
<iframe width="100%" height="315" src="https://www.youtube.com/embed/xK1bZBzowF0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Render
Embed playlists¶
mixin youtube-playlist(id)
- if ("alt" in attributes)
- alt = attributes.alt;
- delete attributes.alt;
- else
- alt = true;
- if ("autoplay" in attributes)
- autoplay = attributes.autoplay;
- delete attributes.autoplay;
- else
- autoplay = false;
- if (autoplay == true)
- autoplay = 1;
- else
- autoplay = 0;
iframe(src=`https://www.youtube.com/embed/videoseries?list=${id}&autoplay=${autoplay}`
frameborder="0"
allow="autoplay;encrypted-media"
allowfullscreen="true"
width="560"
height="315")&attributes(attributes)
- if (alt)
| Your browser does not support iframes.
-
+youtube-playlist
(id)(width="560", height="315")¶ Insert a Youtube playlist
iframe
given an identificator.Arguments: - id (string) – Playlist identificator, corresponds to some letters and numbers located at the end of a playlist url. For example, if a playlist has the url https://www.youtube.com/playlist?list=PL9fkilWKH-6BwYucD1jZ8RZS0wHHCik7d, the identificator is
PL9fkilWKH-6BwYucD1jZ8RZS0wHHCik7d
.
- id (string) – Playlist identificator, corresponds to some letters and numbers located at the end of a playlist url. For example, if a playlist has the url https://www.youtube.com/playlist?list=PL9fkilWKH-6BwYucD1jZ8RZS0wHHCik7d, the identificator is
Usage¶
Input
+youtube-playlist("PL9fkilWKH-6BwYucD1jZ8RZS0wHHCik7d")(width="100%")
Output
<iframe width="100%" height="315" src="https://www.youtube.com/embed/videoseries?list=PL9fkilWKH-6BwYucD1jZ8RZS0wHHCik7d" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Render