mercredi 30 mai 2018

Conditionally add data-attributes in Jekyll

My basic YAML Front Matter for blog posts looks as:

   layout: post
   title:  'Crepes'
   permalink: /crepes/
   src: '/assets/images/crepes.jpg' 
   date:   2018-05-24 21:41:00
   origin: http//...
   ingredients: 
    - ingredient1: amount
    - ingredient2: amount 

Here is my index.html to display entries:

<ul>

</ul>

The problem is: Some posts are supposed to have no origin value, like origin:. And I am looking for a way to add data-origin attribute only if it's value specified in YAML Front Matter.

Liquid give following option:



Is there any way to use it inside of html tag? In my case I expect something like this:

 

Aucun commentaire:

Enregistrer un commentaire