'How to add the value passed in the view to a href attribute in a pug view

Here is the function passing the data to the view

I don't understand what i am doing wrong that i receive an error at this line when the view is loaded

a(href="https://imdb.com/title/"+${m.ids.imdb})

function displayPopularMovies(res){
var pageData={
  title:"Popular",
  movies: null
};
  axios(
{
  url:"/movies/popular",
  baseURL:trakt,
  method:"get",
  headers:{
    "Content-Type":"application/json",
    "trakt-api-version":2,
    "trakt-api-key":process.env.TRAKT_CLIENT_ID
  },
  params: { page: 1,limit:15 }

}
  ).then(function (response){

    pageData.movies=response.data;
    res.render("popular",pageData);
  }).catch(function(error){
    console.log(error);
  });
}

here is the code for popular.pug

extends layout

block layout-content
  h1 Popular movies
  table
   each m in movies
    tr
      td
        a(href="https://imdb.com/title/"+${m.ids.imdb})
         p #{m.title}
      td
        p #{m.year}


Solution 1:[1]

Maybe try something like this for you string interpolation?

      - var url = `https://www.imdb.com/title/${m.ids.imdb}`
      a(href=url) #{m.title}

Solution 2:[2]

It looks like your indentation is off, which is critical in pug. Can you try the following?

extends layout

block layout-content
  h1 Popular movies
  table
    each m in movies
      tr
        td
          a(href=`https://imdb.com/title/${m.ids.imdb}`)
          p #{m.title}
        td
          p #{m.year}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stefan Whittaker-Lee
Solution 2