javascript – How to pass nunjucks variable as Js function parameter-ThrowExceptions

Exception or error:

I’m using javascript to read JSON data from file, and then render it using nunjucks.
At some point, I want to apply a function on a button click, and this function takes a nunjucks variable as argument.

My question is how to pass the nunjucks variable as an argument to my function?

Here is the concerned part of my code.

Thank you


res.render('view.html', {items});


<script type="text/javascript">
  function openArticlePage(arg) {
{% for item in items %}
    <button class="btn" onclick="openArticlePage({{item}});">Read More</button>
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *