Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to get a substring from a string in Nunjucks templating language?

Tags:

nunjucks

If we have value 'cats', I want the substring 'at' (need to delete first and last letters). How can we accomplish that in a Nunjucks template?

like image 907
himabindu Avatar asked Nov 01 '25 12:11

himabindu


1 Answers

You can do this using the JavaScript slice method, like so:

{{cats.slice(1, -1)}}
like image 190
halfer Avatar answered Nov 03 '25 11:11

halfer