Can someone guide me on how to write this specific pug function using handlebars syntax?

Can anyone help me convert the pug code below into handlebars code?

ul
      for product in products
          li #{product.product}
          li #{product.price}

I have found some existing code but I need to populate two points per iteration. Any ideas on how to do that would be appreciated.

handlebars.registerHelper('list', function(n, block) {
    var accum = '';
    for(n in block)
        accum1 += block.fn(n);
    return accum;
});

Thank you.

Answer №1

Give this a shot

<ol>
{{#forEach items}}
   <li>{{item}}</li>
   <li>{{price}}</li>
{{/forEach}}
</ol>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The function myComponent.map does not exist

I am currently storing information that I am trying to pass to a component responsible for creating Tabs and TabPanel components (Material-UI) based on the provided data. Here is how the information is structured: let eventCard = [ { title: "T ...

What steps should I follow to set up a MySQL connection pool in a NodeJS and Express environment?

Creating a MySQL connection is something I can do effortlessly: var mysql = require('mysql'); var pool = mysql.createPool({ connectionLimit : 10, host : 'localhost', user : 'me', password : ' ...

What is the best approach for utilizing AJAX to load content into a Lightbox based on the user's selected trigger?

Developing a custom Lightbox/Thickbox gallery program involves sending user-clicked data to load the appropriate content in the lightbox feature. Below are the important files used in this creation: show-hide-lightbox.js - Contains an Ajax request that ...

Implementing a different background image for every menu item when hovering over its parent

I am trying to figure out how to achieve this. My menu is placed in a container that is 500px high, with a background image. I would like the background image to change when hovering over a parent menu item. I believed I could do this using something like: ...

Adding up the numbers with JavaScript

Hello everyone, I've been working on some transformations and now I'm left with an array of objects: Can anyone help me come up with a flexible function that will generate a new object where each data[i] is the sum of values from the previous ob ...

Is there a method similar to insertBefore that works with arrays and/or HTMLCollections?

Is there a vanilla JavaScript or jQuery function that works like Node.insertBefore(), but for arrays and/or HTMLCollections? An example of what I'm looking for: var list = document.getElementsByClassName("stuff"); var nodeToMove = list[0]; var other ...

Navigating through various arrays within objects on a JSON API with JavaScript: A walkthrough

I am currently working on fetching and displaying data from an API. The specific data I am interested in is located within the 'equipments' array. You can see an example of this array in the image linked below: https://i.sstatic.net/QeBhc.jpg M ...

The absence of a backslash in the JSON string is noticed upon uploading it to the database

After using the JSON.stringify() method in JavaScript to convert my JSON object into a JSON string, I insert it into a database via AJAX posting to a PHP file. $("#saveToDatabase").click(function(){ var place = searchBox.getPlaces(); var locati ...

Is it possible to access a repeater variable within a JavaScript block in AngularJS?

Currently, I am working with AngularJS and attempting to achieve the following: <ul> <li ng-repeat="thing in things"> <a id="mybutton" href="link{{thing.Id}}">Click</a> <script type="text/javascript"> $("#mybu ...

Issue with the save-button in inlineNav of JQGrid not functioning properly after adding a second row for free

We have encountered an issue with adding new rows to several Free JQGrids. When clicking on the ADD icon in inlineNav, a new row appears and clicking the SAVE icon for the first time works correctly. However, when trying to add a second row, the Save butto ...

Converting a function into a JSON string in JavaScript

My code contains a string that looks like this: var jsontext = 'function(prog) {return ' + path + ';}'; I need to convert this string into javascript code. Any ideas on how to accomplish this task? Sincerely, Thomas ...

Tips for converting a select option into a button

Currently, I am working with Laravel to develop my shopping cart. My goal is to implement a feature that allows customers to select the quantity of a product and have the price update accordingly when they click on a specific number. However, I am facing a ...

JavaScript: Searching and Extracting Elements from an Array

I am facing a challenge with a JSON array containing over 2k elements. const Keywords = [ { "key": "hello", "word": "hi. how may i help you?" }, { "key": "how are you?", ...

What is the best way to identify when a page has been refreshed in Reactjs?

Imagine a set of pages with steps: 1, 2, and 3. If a page reloads during the second or third step, it must be directed back to the first step. Is there a way to identify when a page has been reloaded? ...

Preventing mouse controls from moving the cube: a gift/page2 tutorial

(gift/page2) in this snippet: You can observe a demonstration of a red cube rotating on the web page. However, my goal is to prevent the cube from being manipulated by the mouse or fingers on an iPad. I want the cube to remain stationary in its position. ...

Having trouble with HTML not properly rendering within a JSP if() statement

I appreciate the assistance. The issue was due to setting the variable equal to b instead of having b equal the variable. ...

Challenging questions about Ember.js: managing save and delete operations for hasMany relationships

Currently, I am working on my first Ember project which is a quiz generator. I have successfully implemented the functionality to create, edit, and delete quizzes, and save them to local storage. However, I am facing challenges in saving/deleting quiz ques ...

Tips on deleting a nested JSON key?

Here is an example of my JSON structure: var data = [{ "ID" : 3, "discRec" : "Some sample record", "Tasks" : [{ "ID" : 7, ...

Monitoring $scope modifications within a directive: A simple guide

I am currently working with a directive that looks like this: app.directive('selectedForm', function(MainService) { return { scope: { formName: '=currentForm' }, restrict: 'E', ...

Steps on incorporating fresh data into JSON format

pin = [ { "id": 26, "comments": [ { "id": 2, "username": "user", "description": "example", "pin": 26, "commenter": 1 }, ...