You are here

public function Generator::paragraphs in Style Guide 8

Same name and namespace in other branches
  1. 2.x src/Generator.php \Drupal\styleguide\Generator::paragraphs()

Generate paragraph(s) of random text.

Parameters

int $size: The number of paragraphs to return.

bool $render: Allow to choose render the paragraph or return renderable array.

Return value

array|string Renderable array or string of HTML paragraphs.

Overrides GeneratorInterface::paragraphs

File

src/Generator.php, line 147

Class

Generator
Class Generator.

Namespace

Drupal\styleguide

Code

public function paragraphs($size = 5, $render = FALSE) {
  $text = $this
    ->lorem($size, 0, 'mixed', TRUE, TRUE, TRUE);
  $output = [];
  foreach ($text as $item) {
    $output[] = [
      '#type' => 'html_tag',
      '#tag' => 'p',
      '#value' => trim($item),
    ];
  }
  return $render ? render($output) : $output;
}