Lego2012
9/26/2016 - 11:31 PM

Jekyll - Includes with Parameter

Jekyll - Includes with Parameter

<!-- 
In more complicated situations you can also pass parameters to an include. In this example we’re going to add YouTube videos to the site which we always want presented in a consistent way. We need them to be centered and a particular size.

Let’s create a new include, _includes/youtube.html. In this file we’ll create the structure for displaying a YouTube video and have a placeholder for the YouTube video id. We can access parameters passed to an include using include.variable_name. 
-->

<div class="spacing youtube">
  <iframe width="560" height="315" src="https://www.youtube.com/embed/{{ include.youtube_id }}" frameborder="0" allowfullscreen></iframe>
</div>

<!-- 
Now we can use this include throughout our site and pass in the video id we want to display: 
-->

{% include youtube.html youtube_id="YIiHiMXOeYU" %}