Using the standard Django templating system, is there any snippet/reusable template tag to have the first n words in a piece of text wrapped in a tag so I can style them?
What I’m ideally looking for:
{{item.description|wrap:"3 span big"}}
which outputs:
<span class="big">Lorem ipsum dolor</span> sit amet, consectetur adipiscing elit.
If this would be, for any reason, not feasible or really difficult to obtain, I can use JavaScript and do it client side, but I’d like more to be able to do it on page output.
It turns out that writing a filter is really easy (and works exactly the intended way).
This could be made a lot safer, but does the job (and won’t break unless someone passes html as parameters):