Lorem ipsum view helper

by Naneau

A while ago I wrote a little lorem ipsum class. I use it a lot when creating mock-ups. Having realistic filler text really helps with visualizing things.

When I wrote about view helpers the other day it dawned on me that I’ve never posted the view helper I created for use with the lorem ipsum class. It’s the perfect thing to wrap in a view helper. It’s something you’d use in your views, and you don’t want to write the code to use the class directly into your views. Really, you don’t ;)

Anyway, here it is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
/**
 * LoremIpsum.php
 *
 * @category   Naneau
 * @package    Naneau_View_Helper
 * @copyright  Copyright (c) 2007 Maurice Fonk - http://naneau.nl
 * @version    0.1
 */


require_once 'Naneau/Text/Filler.php';

/**
 * Naneau_View_Helper_LoremIpsum
 *
 * get a number of lorem ipsum paragraphs (random filler text)
 *
 * @category   Naneau
 * @package    Naneau_View_Helper
 * @copyright  Copyright (c) 2007 Maurice Fonk - http://naneau.nl
 */

class Naneau_View_Helper_LoremIpsum {
    public function loremIpsum($count = 2, $html = true) {
        return Naneau_Text_Filler::getParagraphs($count, $html);
    }
}

Use it like this (in your view scripts):

1
<?php echo $this->loremIpsum(5); /* 5 paragraphs */ ?>

You have to have the original class in your library, though.