Passing data to tpl file

Game development with Board Game Arena Studio
Post Reply
tony58uk
Posts: 15
Joined: 23 March 2023, 20:09

Passing data to tpl file

Post by tony58uk »

Hi all,

I'm having an issue I would like some help with please.

I'm trying to create custom player boards in the score area.

In the tpl file I have the following code

Code: Select all

const jstpl_player_board = (type) => '<div class="cp_board"> <div class="die dietype_${type}" id="cp_die_${id}"></div></div>';
and in the JS file I have this code

Code: Select all

this.getPlayerPanelElement(player.id).innerHTML = jstpl_player_board(player.god);
Data is not being passed into the tpl, it must be something simple I am missing?

Cheers
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: Passing data to tpl file

Post by thoun »

Do you have errors in the console? Your template interpolates type and id, but only have type as a parameter. It should be (type, id) => and be called accordingly.
tony58uk
Posts: 15
Joined: 23 March 2023, 20:09

Re: Passing data to tpl file

Post by tony58uk »

I've changed it to this

Code: Select all

const jstpl_player_board = (type) => '<div class="cp_board"><div class="die dietype_${type}"></div></div>';
But it's still not passing data through.

When I inspect the element ${type} is there instead of the data I'm trying to pass. I'm missing something silly I know, but cannot find anything on the web.

Cheers
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: Passing data to tpl file

Post by thoun »

Oh yes, you're using single quote (') instead of backticks (`) so it doesn't interpolate at all.
tony58uk
Posts: 15
Joined: 23 March 2023, 20:09

Re: Passing data to tpl file

Post by tony58uk »

OMG

Fixed, thanks. I knew it was something silly!!!!
Post Reply

Return to “Developers”