Search code examples
pythonhtmlstringjinja2string-concatenation

String concatenation inside angular brackets in HTML


How do I concatenate strings inside jinja brackets {{ }} in HTML?

Ex: <img src="{{ image.file.name }}">

I need to concatenate with the image.file.name.

ex: <img src="{{ 'https://s3.ap-south-1.amazonaws.com/bucket_name/images/' + image.file.name }}">

But his didn't work. Please help.


Solution

  • you should write like this

    <img src="https://s3.ap-south-1.amazonaws.com/bucket_name/images/{{ image.file.name }}">
    

    in jija you don't have to concat with + it will replace {{}} without it