-
-
Save willthemoor/749f7ee2a3e4b59e6080 to your computer and use it in GitHub Desktop.
Lorem Ipsum generator mixin for Jade (single paragraph)
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
//- ---------------------------------- | |
//- Simplified version. | |
//- | |
//- Usage: | |
//- include lorem | |
//- p: +lipsum(42) | |
//- ---------------------------------- | |
mixin capitalize(string) | |
= string.charAt(0).toUpperCase() + string.slice(1) | |
mixin lipsum(howmany) | |
- var words = ['consectetur', 'adipiscing', 'elit', 'curabitur', 'vel', 'hendrerit', 'libero', 'eleifend', 'blandit', 'nunc', 'ornare', 'odio', 'ut', 'orci', 'gravida', 'imperdiet', 'nullam', 'purus', 'lacinia', 'a', 'pretium', 'quis', 'congue', 'praesent', 'sagittis', 'laoreet', 'auctor' ] | |
- for (var i = 0; i < howmany; i++) { | |
- var nextWord = words[Math.floor((Math.random()* ( words.length - 1 ) ))] | |
if (i == 0) | |
mixin capitalize(nextWord) | |
else | |
= ' ' + nextWord | |
if i == howmany - 1 | |
= '.' | |
- } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, I've take your code for testing my codepen : https://codepen.io/YggLife/pen/zaexEM?editors=1000
And you've a syntax error on line 18 => mixin capitalize(nextWord)
For Pug syntax, you must change it by => +capitalize(nextWord)
I've create a fork of your codepen ? https://codepen.io/YggLife/pen/jKdEYa?editors=1100