Search code examples
nunjucks

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


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?


Solution

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

    {{cats.slice(1, -1)}}