PHPackages                             mrnebbi/craft-template-tools - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. mrnebbi/craft-template-tools

ActiveCraft-plugin[Templating &amp; Views](/categories/templating)

mrnebbi/craft-template-tools
============================

Craft CMS Plugin to provide some extra functionality to Twig templates

2.0.0(7y ago)118PHP

Since Sep 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/mrnebbi/craft-template-tools)[ Packagist](https://packagist.org/packages/mrnebbi/craft-template-tools)[ RSS](/packages/mrnebbi-craft-template-tools/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (5)DependenciesVersions (2)Used By (0)

Template Tools
==============

[](#template-tools)

[![version 2.0.0](https://camo.githubusercontent.com/1982e7c2bb4f616c9bd86ee7d550184cfdc6a2bd33191d49fa48d6112889461c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d322e302e302d627269676874677265656e2e737667)](https://github.com/mrnebbi/craft-template-tools)

A Craft plugin to provide twig filters to help with template building.

---

Please note: As of version 2.0, I've removed the Query Strings functionality from template tools. Please use my [Query Strings plugin](https://github.com/mrnebbi/craft-query-strings).

---

firstTag
--------

[](#firsttag)

Easily add a class, ID, or other attribute to the first element of a specific type. Useful for adding a class to the first paragraph.

### Add a class

[](#add-a-class)

```
{{ content|firstTag('classname') }}

```

By default this adds a class name to the first P tag. Add a `.` or `#` to set an ID or Class.

### Add an ID

[](#add-an-id)

```
{{ content|firstTag('#idname') }}

```

### Add to a non paragraph

[](#add-to-a-non-paragraph)

Sets a class name or ID to the first tag of a type specified by you. e.g.

```
{{ content|firstTag('classname','h2') }}

```

Add a `.` or `#` to set an ID or Class.

### Add custom attribute and value to a non paragraph

[](#add-custom-attribute-and-value-to-a-non-paragraph)

Sets a value for a specified attribute to the first tag of a type specified by you.

```
{{ content|firstTag('slider1','img','data-slider') }}

```

```
{{ content|firstTag('lead','h2','data-heading') }}

```

getFirstParagraph
-----------------

[](#getfirstparagraph)

Retrieve the first paragraph from content.

### Get paragraph only

[](#get-paragraph-only)

```
{{ content|getFirstParagraph }}

```

### Get paragraph and remove P tags

[](#get-paragraph-and-remove-p-tags)

Add a flag of true to remove the P tags from the content.

```
{{ content|getFirstParagraph(true) }}

```

wrapLinesInTag
--------------

[](#wraplinesintag)

This wraps any lines in multiline text in a tag of your choosing.

```
{{ content|wrapLinesInTag('span') }}

```

preserveQueryStrings
--------------------

[](#preservequerystrings)

Removed Query Strings functionality. Please use my [Query Strings plugin](https://github.com/mrnebbi/craft-query-strings).

The Preserve Query String filter allows you to add `|preserveQueryStrings` to any URL output in twig, and it will keep the query strings as they should appear in the URL.

getQueryStrings
---------------

[](#getquerystrings)

Removed Query Strings functionality. Please use my [Query Strings plugin](https://github.com/mrnebbi/craft-query-strings).

Pull an array of query strings from Craft. This gets around the problem of duplicated query string keys being lost, turning them into an array you can loop through.

An array will be returned with objects. Use `.key` and `.value`.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2846d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/708691?v=4)[Ian Nebbiolo](/maintainers/mrnebbi)[@mrnebbi](https://github.com/mrnebbi)

---

Top Contributors

[![mrnebbi](https://avatars.githubusercontent.com/u/708691?v=4)](https://github.com/mrnebbi "mrnebbi (32 commits)")

---

Tags

craft-plugincraftcmscraftcms-plugintwig-extension

### Embed Badge

![Health badge](/badges/mrnebbi-craft-template-tools/health.svg)

```
[![Health](https://phpackages.com/badges/mrnebbi-craft-template-tools/health.svg)](https://phpackages.com/packages/mrnebbi-craft-template-tools)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3861.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.0k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.2k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

281.8k](/packages/webkinder-sproutset)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
