findFirstParagraph

Finds the first paragraph tag in a rendered HTML string and returns its content. This function can be used to extract the first text block form a block variable to be used separately as a teaser text for the page in a pagelist.

@{ +main | findFirstParagraph }

To get the first paragraph of a Markdown variable, the markdown functions has to be applied before.

@{ text | markdown | findFirstParagraph }

Example

One use case for this function is to render short previews of pages in a pagelist in order to create overview pages for blog posts.

<@ foreach in pagelist @>
  <a href="@{ url }">
    <h3>@{ title }</h3>
    <p>@{ +main | findFirstParagraph }</p>
    <@ with @{ +main | findFirstImage } { width: 500 } @>
      <img src="@{ :fileResized }" />
    <@ end @>
  </a>
<@ end @>
findFirstImage floor