I'm making a theme for Bolt (CMS) and it uses the Twig
engine.
The website contains articles so I get an article's field like this {{ article.body }}
Now what I wanted to achieve was get the first letter of the body of the article and make it big and then display the rest of the article's body (without this first character) normally, you sometimes see this in books. I managed to do that and I successfully change the style of the first character.
However, using most functions that Twig offers in the documentation, I most often get a "<" as the first symbol as when typing the body of the article in the administration panel it automatically puts a <p>
tag to the start.
Is there a way to overcome this?! I wouldn't want my client to have to delete the <p>
tag every time. I thought there would be an easy way to get the body without any html in it or something else suitable for my use case.
The way it currently works beautifully:
<span class="firstcharacter">{{ article.body[:1] }}</span> {{ article.body[1:] }}</p>
but this relies on the article not starting with any html