leowebguy/lorem-ipsum

Lorem Ipsum Generator for Craft

Installs: 439

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:craft-plugin

2.0.0 2024-03-27 03:21 UTC

This package is auto-updated.

Last update: 2024-04-27 04:06:05 UTC


README

Extending PHP Lorem Ipsum by @joshtronic

Installation

Open your terminal and go to your Craft project:

composer require leowebguy/lorem-ipsum -w && php craft plugin/install lorem-ipsum

Usage

The plugin exposes these methods to Twig:

Words

{{ craft.lorem.w(1) }} >> 1 word
{{ craft.lorem.w(5) }} >> 5 words

Sentences

{{ craft.lorem.s(1) }} >> 1 sentence
{{ craft.lorem.s(2) }} >> 2 sentences

Paragraphs

{{ craft.lorem.p(1) }} >> 1 paragraph
{{ craft.lorem.p(2) }} >> 2 paragraphs

 

Need it wrapped ? Just use Twig {{ tag }}

{{ tag('p', { 
  text: craft.lorem.w(10), 
  class: 'text-center' }) 
}}

output >> <p class="text-center">lorem ipsum...</p>

With twig utils

craft.lorem.w(10)|title << Uppercases the first character of each word in a string.
craft.lorem.w(10)|upper << Formats a string into “UPPER CASE”.
craft.lorem.w(10)|ucfirst << Capitalizes the first character of a string.
craft.lorem.w(10)|lower << Formats a string into “lower case”.

You may also provide a tag for sentences and paragraphs

{{ craft.lorem.s(2, 'p') 

output >> <p>lorem ipsum...</p><p>lorem ipsum...</p>

 

Great for data templating fallback!

{% set data = {
    heading: entry.heading ?? craft.lorem.w(6),
    copy: entry.copy ?? craft.lorem.w(32)
} %}

<div>
  <h2>{{ data.heading }}</h2>
  <p>{{ data.copy }}</p>
</div>