jekyll,

Liquid-Lipsum Jekyll Plugin

Fèlix Fèlix Segueix 09/11/2013 · 3 minuts de lectura
Liquid-Lipsum Jekyll Plugin
Compartir amb...

I’ve just finished my first Jekyll plugin: the jekyll-liquid-lipsum-plugin. This Jekyll plugin inserts random text inside your posts, in order to test how the a long text will appear. It’s specially useful playing with the CSS of your site.

The plugin

You can access it’s source code, clone it and/or use it from Gitlab: https://gitlab.com/felix.galindo/jekyll-liquid-lipsum-plugin

This plugin allows you to insert random text in your posts, just to test how will appear some new environment or a new CSS class.

Installation

Just copy the liquid_lipsum.rb file to the _plugins folder.

Requirements

None. :)

Configuration

None. :)

Usage

It’s usage is simple. For example, you insert this line in one of your posts:

{% lipsum %}

And you’ll get something like this:

Aenean id lacinia neque nec bibendum odio risus a arcu imperdiet metus id velit augue id magna iaculis quis, pretium quam iaculis quis, sit amet nibh ullamcorper nec, pretium quam nonummy ac, erat libero tristique tellus, turpis at pulvinar vulputate, sed nisl molestie nec bibendum odio risus erat libero tristique tellus, a arcu imperdiet pretium quam turpis at pulvinar vulputate, sit amet nibh rutrum non, pretium quam augue id magna ullamcorper nec, porttitor ut, porttitor ut, nec bibendum odio risus sit amet nibh sit amet ante.

As you can see, a full paragraph of random text will substitute the original liquid tag.

Each paragraph will have a beginning, a middle part and an ending. The size of the paragraph corresponds to the number of middle parts. A number of 3 will have 3 middle parts.

The following paragraph has a size of 1: Nam quis nulla ullamcorper nec, sit amet ante. The begining is “Nam quis nulla”, the middle part is “ullamcorper nec,” and the ending is “sit amet ante”.

The beginings, middle parts and endings are taken randomly from 3 different pools of text.

The tag allows up to three numbers as parameters:

  • The first number represents the number of paragraphs to be generated,
  • The second number is the minimum size of the paragraph (number of middle parts).
  • The third number is the maximum size of the paragraph (number of middle parts).

Combining this, you can have the following situations:

Use cases of the tag:

Usage Result
{% lipsum %} 1 paragraph. Random length between 10 and 30
{% lipsum n %} n paragraphs. Random length between 10 and 30
{% lipsum n l %} n paragraphs. Exactly a length of l
{% lipsum n l1 l2 %} n paragraphs. Random length between l1 and l2

You can improve or modify the behaviour of this liquid tag by simply editing its source code. There you can change the sentence parts to your wishes by simply editing the three arrays of strings from which the generator takes the text parts.


Fèlix
Written by Fèlix Segueix
Sóc el Fèlix! 42!