Domanda

As we know,we can output in slim like this:

div
  h1 =session[:mem]

But now,I have to output an var in javascript which embedded in slim.

For example:

javascript:
  var a=(=session[:mem]);

Obviously,this will raise an error.

So I wan to know how to output an var in javascript.

È stato utile?

Soluzione

Try:

javascript:
  var a=#{session[:mem]}; # or var a="#{session[:mem]}";
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top