I am inserting the following HTML into the DOM from within in AJAX success callback. The AJAX call provides data
, which contains the fields used below. For every player1
and player2
there is an associated image saved in assets/images as "#{first_name}_#{last_name}"
. How can I replace the data
fields in the HTML below with ERB? Specifically, I would like to use rails' image_tag
so that the image's url includes the alpha-numeric code (digest) that is appended to the image url in the production environment (Heroku).
Thanks!
getFullMatchupHTML = (data) ->
fullMatchupHtml =
'<div class="row">' +
'<div id="matchupID" data-matchupid=' + data.matchup.id + '></div>' +
'<div id="mpcontainer" class="">' +
'<div id="mp1" class="span5 mp">' +
'<h3>' + data.player1.first_name + ' ' + data.player1.last_name + '</h3>' +
'<h4>' + data.player1OpponentTeamName + '</h4>' +
'<div id="mpimage1" class="mpimage">' +
'<img src="/assets/' + data.player1.first_name + '_' + data.player1.last_name + '.jpg" alt="' + data.player1.first_name + '_' + data.player1.last_name + '" class= "playerpic" >' +
'</div>' +
'</div>' +
'<div id="mp2" class="span5 mp">' +
'<h3>' + data.player2.first_name + ' ' + data.player2.last_name + '</h3>' +
'<h4>' + data.player2OpponentTeamName + '</h4>' +
'<div id="mpimage2" class="mpimage">' +
'<img src="/assets/' + data.player2.first_name + '_' + data.player2.last_name + '.jpg" alt="' + data.player2.first_name + '_' + data.player2.last_name + '" class= "playerpic" >' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</br>' +
'<div class="row" id="num-votes-row" class="hiddenVoteRow">' +
'<div class="">' +
'<div id="mpts1" class="span5">' +
'<h2>' + data.ptsplayer1 + '</h2>' +
'</div>' +
'<div id="mpts2" class="span5">' +
'<h2>' + data.ptsplayer2 + '</h2>' +
'</div>' +
'</div>' +
'</div>'