Search code examples
backbone.jspug

Backbone with Jade issues with tag parameters


Very annoying problem I'm facing. I want to dynamically enter the url of an image using backbone. I thought the following would do.

img(src="<%= image %>" width="100%" height="auto")

However the src url does not get replaced correctly and stays as "<%= image %>" when I do:

this.$el.html(this.template(this.model.toJSON()));

Any suggestions?


Solution

  • You can write like this and have the jade syntax intact.This way the underscore variable can be referred directly.

      img(src!="<%= image %>" width="100%" height="auto")