Issue with javascript templates in game.tpl file
Posted: 22 February 2021, 16:42
var jstpl_movement='<div class="movement movement${type}${dirx}${diry}" id="loc_${x_y}"></div>';
var jstpl_piece='<div class="piece" id="piece_${kind}_${owner}" style="left: ${LEFT}px; top: ${TOP}px; background-image: url('${pref}${tile}_${color}_${side}.jpg') ;"></div>';
Not sure how to post code, but these are my two jstpl templates in my game.tpl file. I'm trying to load the game pieces like I load the movement icons. If I take out the url('...') section in the background-image: of the 2nd template and replace it with "none" everything works fine. If I put anything in there with the url parameter (even a hard coded image that DOES exist), I get a JS error that jstpl_movement can't be found (which is NOT the one with the url parameter). I'm not actually using jstpl_piece anywhere yet as I can't get past this problem.
var jstpl_movement='<div class="movement movement${type}${dirx}${diry}" id="loc_${x_y}"></div>';
var jstpl_piece='<div class="piece" id="piece_${kind}_${owner}" style="left: ${LEFT}px; top: ${TOP}px; background-image: none;"></div>';
The above works without a problem (but leaves me with the issue of still needing to dynamically load the piece image). Putting ANYTHING in the background-image section other than none results in the error.
I'm not sure how using the browser debugger would be helpful since it's not actually a bug in the JS code. Any ideas on how to troubleshoot this beyond what I've already done? Am I doing something that I just simply shouldn't be using a JS Template for?
thx
var jstpl_piece='<div class="piece" id="piece_${kind}_${owner}" style="left: ${LEFT}px; top: ${TOP}px; background-image: url('${pref}${tile}_${color}_${side}.jpg') ;"></div>';
Not sure how to post code, but these are my two jstpl templates in my game.tpl file. I'm trying to load the game pieces like I load the movement icons. If I take out the url('...') section in the background-image: of the 2nd template and replace it with "none" everything works fine. If I put anything in there with the url parameter (even a hard coded image that DOES exist), I get a JS error that jstpl_movement can't be found (which is NOT the one with the url parameter). I'm not actually using jstpl_piece anywhere yet as I can't get past this problem.
var jstpl_movement='<div class="movement movement${type}${dirx}${diry}" id="loc_${x_y}"></div>';
var jstpl_piece='<div class="piece" id="piece_${kind}_${owner}" style="left: ${LEFT}px; top: ${TOP}px; background-image: none;"></div>';
The above works without a problem (but leaves me with the issue of still needing to dynamically load the piece image). Putting ANYTHING in the background-image section other than none results in the error.
I'm not sure how using the browser debugger would be helpful since it's not actually a bug in the JS code. Any ideas on how to troubleshoot this beyond what I've already done? Am I doing something that I just simply shouldn't be using a JS Template for?
thx