Last active
June 19, 2020 14:38
-
-
Save herrkessler/d746f2746ead921c5bd4b06264d910d2 to your computer and use it in GitHub Desktop.
picture mixin for pug.js - http://codepen.io/herrkessler/pen/ZeZKgW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mixin picture(path, name, type) | |
picture | |
each val in type | |
source(srcset=path + "/" + name + "." + val type="image/" + val) | |
img(src=path + "/" + name + ".jpg" alt=name) | |
+picture('path/to', 'image', ['jpg','webp']) | |
// Compiles to | |
//------------------------ | |
// <picture> | |
// <source srcset="path/to/image.jpg" type="image/jpg"> | |
// <source srcset="path/to/image.webp" type="image/webp"> | |
// <img src="path/to/image.jpg" alt="image"> | |
// </picture> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment