Questions tagged [handlebars.js]

Handlebars stands tall as a remarkable JavaScript library designed for seamless templating.

Suggestions for addressing the "required" attribute issue with express-handlebars?

I am currently utilizing express-handlebars and have crafted a home.hbs (home.handlebars) file where everything is functioning correctly except for one specific issue. The "required" attribute is not working as expected, and it is also not being highligh ...

Built-in Handlebars helper for nested iteration - no results displayed

I'm currently facing an issue with using an iteration helper within another one. Strangely, the inner helper isn't producing any output. Here's a snippet of the handlebars template I'm working with: {{#people}} <h4>{{firstNa ...

Having difficulty displaying form errors using handlebars

My form validation is not working properly. When I enter incorrect information, it alerts correctly, but when I submit the form, it returns [Object object]. What could be causing this issue in my code and how should I handle the data? https://i.stack.imgu ...

Direct back to the current page post deleting entry from mongodb

After removing data from MongoDB, how can I redirect to the same view (handlebar)? I tried using res.render, but it shows that the website cannot be reached. Thank you for your assistance. Controller Logic var express = require('express'); va ...

What is the best way to utilize the handlebars-helpers library within an express.js application?

Currently I am using hbs as my template engine in express.js. The handlebars-helpers library from assemble is something that I find extremely useful. However, I am unsure about how to integrate this library into my project. I have also been unable to loca ...

Having trouble setting the audio source path in a handlebars file

homepage.html <script> function playAudio(audio_src){ console.log('audio src: ' + audio_src); var player = document.getElementById('player'); player.src = audio_src; player.load(); player.play(); return f ...

How to send data to a compiled handlebars template in Express.js

I have been attempting to pass a variable to a handlebars compiled template, but instead of the correct value, I am getting a blank. Even though the console logs show the right object, I seem to be making a silly mistake somewhere. Despite trying multiple ...

Retrieve the identification of elements with dynamically generated ids

I've dynamically generated a set of elements using Handlebars, as shown below {{#floor as |room i|}} <div class="btn-group-toggle" data-toggle="buttons" > <label class="btn btn-secon ...

Is it safe to use handlebars' default escaping in HTML attributes?

Currently, I am working on a project where various HTML escaping methods are being utilized. Some properties are escaped in the backend and displayed as raw strings using triple handlebars {{{escaped-in-backend}}}, while others are passed from the backend ...

Deleting a MongoDB entry with Node.js and Handlebars is not possible

I have been struggling to figure out how to delete an entry but haven't had any success yet. I've tried using "post" instead of "delete" without any luck and even attempted the action request on the html, but still no success. I'm really stu ...

What is the process of invoking a node module in an express-rendered view?

Struggling to comprehend how to pass data to my view. Currently integrating the Mozscape node module into an application and unsure of how to send the information to the view. My assumption is that I should create the object in the router, call the functio ...

Attempting to save MongoDB data into a variable for integration with Handlebars.js

Having an issue with storing MongoDB data in a variable to display in HTML using hbs. The specific error message is TypeError: Cannot read property 'collection' of undefined. Here's the code snippet I have written: const express = require('express'); cons ...

Utilize Express Node to display API information on HTML pages using Handlebars template

I'm seeking assistance in rendering data from an API to HTML using handlebars. I'm a bit puzzled on how to properly showcase the data on the webpage. Here's what I have so far: ROUTES FOLDER/FILE: const express = require('express'); const router = expr ...

Is there a way to handle templates in AngularJS that is reminiscent of Handlebars?

Is there a way to handle an AngularJS template using a syntax similar to Handlebar? <script type="text/ng-template" id="mytemplate"> Name is {{name}} </script> I know how to retrieve the template using $templateCache.get('mytemplate'), but ...

Using Handlebars JS to incorporate HTML tags such as <li>, <br>, and more in your data

Is there a way to use handlebars to display a list of data in an unordered format, with "title" and "articles" as the main categories? The issue arises when some of the articles contain HTML tags, such as <a> for links. In my current code, instead of ...

Comparing Express.js View Engine to Manual Compilation

Currently, I am utilizing Express.js along with the hbs library to incorporate Handlebars templates in my application. Lately, I've delved into establishing a build system using gulp for my app and stumbled upon packages like gulp-handlebars. My query re ...

Sending compiled parameters to directives for ng-click

I am attempting to implement ng-repeat in Angular version 1.6.x The keys returned by getToggle are ['card1', 'card2'] <li ng-repeat="fi in getToggleKeys()"> <a ng-click="actions.toggleMode($event, '{{fi}}')" href="#"</a> & ...

Automate your transformations with a Gruntfile that includes grunt-contrib-watch, browserify, and hbsfy (handlebars) plugins

I am fairly new to the world of tools like grunt, browserify, and handlebars. I have set up my gruntfile.js to monitor changes in certain .js files and then automatically run the default browserify bundle command on them. Below is a snippet from my current ...

Utilizing express-handlebars to access variables that have been declared within the client-side javascript

Currently, I am delving into the world of handlebars for templating on my website. As a user of node.js, I opted to utilize the popular express-handlebars module due to its extensive support within the community. Setting up the basic configuration was str ...

What is the process for creating and registering custom Handlebars functions?

Despite spending plenty of time searching, I am still unable to find detailed information on where exactly to place my custom handlebars helpers. Should they be added in a <script> tag within my webpage's .hbs file? Or should I include them in a ...

An Express Handlebars callback function is mandatory

Recently, I've been attempting to incorporate handlebars into my express project. However, I keep encountering an error in the node.exe console indicating that a callback function is needed. Can anyone offer some assistance with this issue? Here's a link ...

Looking for a demonstration using dust.js or handlebars.js in a two-page format with express3.x and node?

Currently, I am in the process of selecting a templating engine to use. While I have come across numerous single-page examples utilizing template engines, I am specifically searching for a practical example that demonstrates handling two distinct pages whi ...

Loading handlebar templates for sending emails with nodemailer from a remote server is simple and straightforward

I currently have a nestjs application with a POST /email endpoint that utilizes nodemailer to send emails based on handlebar templates. The template used depends on the selection made in the API call (template=xxx). For example, http://localhost:3000/< ...

Enlist partial components in express-handlebars

I'm having trouble registering partials in my app. Despite trying various solutions from other sources, nothing seems to work for me... I have set up the express handlebars as follows: import { engine } from 'express-handlebars'; const __fi ...

How to Populate .handlebars Templates with Multiple SQL Results in Express

As a newcomer to the world of Express and Node.js, I am eager to understand how to display multiple SQL results on different elements of a web page. Though it may be a simple question for some, I am unsure how to proceed and would greatly appreciate any g ...

Achieving Efficiency with Handlebars: Streamlining Remote Template Organization and

I am looking for a way to better organize my HB template by splitting it into different HTML files. In this case, I have created a file called helpers.html. This file contains two script tags: <script id='alert' type='text/template>...</script> ...

How long does it take for node and express to load classes in milliseconds

Currently, I am utilizing node express without the use of a template engine. Instead, I am creating my HTML file and sending it through response.send(template); which has been working well for me thus far. However, as I begin incorporating more complex ta ...

Rendering with Handlebars in Express 4 without using a layout template

Can an express 4 app render a view without utilizing a layout? In my project, there is a layout.hbs file that is being utilized without any explicit registration. While this works for most views, how can I render just a single view without the layout? ...

Can templates be nested within other templates using different contexts?

I am in the process of developing an application using nodejs and handlebars. My goal is to create a layout template and insert various individual components into that layout. Each component will have its own handlebars template and context. e.g. layout. ...

I am experiencing an issue with the functionality of Handlebars registerPartial()

Check out my code snippet on JsFiddle Error Message: Uncaught Error - The partial social could not be found Note: I have made sure to include all necessary libraries. Looking forward to your assistance. Thank you! ...

Exploring Handlebars.js: Understanding the Scope of Global Contexts

If I have a static list of cached users within my application under App.Users, there will likely be various instances where I need to display the list of users. Typically, I would just pass the list along with the context to the template. var tmpl = Handl ...

Is the item positioned above another item instead of being positioned to the left of it?

Looking for help with my mobile navigation setup. I want to add text that says ' ...

Building an anchor tag that employs the HTTP DELETE method within an Express.js app

Recently, I delved into using express.js with handlebars.js as my template engine. One task I wanted to tackle was creating a delete link that followed RESTful principles and used the HTTP DELETE verb instead of GET. After some trial and error, I discover ...

Unable to access the 'fn' property of undefined in Handlebars causing a TypeError

I encountered an issue with my custom handlebars helper. When I fail to define values for the parameters, I receive the following error message. module.exports = function(src, color, classatr, options) { if (typeof src === 'undefined') src = ''; ...

Donut chart in SVG format failing to display properly in email messages

Here is an example of a donut chart that I am working with: <div class="donut-chart" style="position: relative;"> <svg width="100%" height="100%" viewBox="0 0 42 42" class="donut"> ...

The server is unable to process the .get() request for the file rendering

Struggling with basic Express routing here. I want the server to render 'layout2.hbs' when accessing '/1', but all I'm getting is a 304 in the console. Here's the error message: GET / 304 30.902 ms - - GET /style.css 304 3.370 ms - - GET /print2.css 304 ...

Unable to retrieve the .attr() from a button that was created using handlebars

I am currently working on developing a web scraper as part of a homework task that involves using Express, Mongoose, Cheerio/axios, and Handlebars. In my "/" route, I retrieve the Mongoose objects and use Handlebars to display them on the page in individua ...

Unable to find the view "index.html" in NodeJS with Express and Handlebars

I've been exploring Node.js and recently dove into Express to create a basic app. My goal was to use Handlebars as the view templating engine, but I'm encountering an issue - it can't locate the "index.html" view. The index.html file is in the same direct ...

What is the best way to arrange the keys of a JavaScript object in a customized

I am struggling to find a way to custom sort a JavaScript object properly. For example, I have the following object: var test = { 'yellow': [], 'green': [], 'red': [], 'blue': [] } And an array with values like: var arr = ['red', 'green', 'blue', ...

Transfering data to Handlebars while rendering a template

Is there a method to pass a variable to a handlebars template during its rendering process? Below is the template in question: <script id="listingTopics" type="text/x-handlebars-template"> {{#each this}} <div class="wrapper_individual_listing ...

Is there a comparable option to Jades extend in the world of Handlebars?

Considering transitioning the templating language of my express app from Jade to Handlebars. I am curious if there exists a similar directive in Handlebars as the Jade extend directive. ...

Is my front-end JavaScript fetch request mistakenly being sent as a GET instead of a POST?

On clicking the submit button, a fetch request is triggered. Strangely, in the developer tools, it shows up as a GET request. I tested the request using Insomnia and it returned the handlebars site to me without any of my console logs appearing on either ...

What is the process of implementing a page change using a GET request in JavaScript using Node.js and Express?

Within this application, users are provided with a table where they can input data. Each row in the table is equipped with an "Edit" button that, when clicked, should redirect them to a new page labeled "/update" where modifications to the specific row can ...

cycle through several handlebars entities

Hey friends, I could really use your help right now. I'm attempting to iterate through these objects using handlebars. RowDataPacket { idUser: 1, username: 'xxxxxx', password: 'xxxxx', fullname: 'Julian Rincon'}, RowDat ...

Tips for transitioning to handlebars for data display using mongodb

Seeking help on transitioning from EJS to Handlebars for displaying content. I am relatively new to Node.js and would appreciate any suggestions on how to implement the following code in Handlebars. Which templating engine is more effici ...

Emberjs 1.0: Data Changes don't Refresh Computed Property and Template

In my Ember.js application, I am using a datepicker which is integrated for selecting dates. When a date is clicked on the datepicker, a computed property should compare the selected date with the dates available in the timeslot to check for a match. Based ...

Tips for enlarging an image by tapping on it in handlebars

I currently have the handlebars template engine integrated with node.js, and I'm facing an issue where thumbnail images from the database are displaying at a fixed width and height of 70. Is there a way to enable users to click on these images in order to ...

There was an error in locating the JavaScript file within the Node.js Express Handlebars application

My website is not displaying the .js file, css file, or image from the public folder. Here are the errors showing up in the console: GET http://localhost:8080/assets/images/burger.jpg 404 (Not Found) GET http://localhost:8080/burgers.js net::ERR_ABORTED ...

dividing Handlebars HTML content into different files or sections

I am looking to design a single route webpage, but I would like to divide the HTML code into multiple files. When rendering this particular route, my goal is for the rendered file to pull content from different template files and combine them into one coh ...

Using a .js file outside of the public folder in a Node Express App: A Step-by-Step Guide

Seeking guidance as a beginner with Node Express and needing assistance to resolve the following issue. This is the folder structure of my Node Express application: https://i.stack.imgur.com/sNtrT.png Below is a snippet of my app.js code: var express = ...

Utilizing app.set and app.engine functions in the Express framework

I am currently learning from a Node.js tutorial. There are two lines in the tutorial that I'm not entirely confident about: app.set('view engine', 'html'); app.engine('html', hbs.__express); After looking at the documentation for app.set, it simply stat ...

Encountered an issue locating the view within the directory while using Express Handlebars

I've been working with the basic app layout generated by Express Generator and I'm trying to customize it for Handlebars. Snippet: var exphbs = require('express-handlebars'); var app = express(); // view engine setup app.set('views', path.join(__dirnam ...

Having trouble retrieving JSON data using jQuery and Handlebars?

Hey there, I'm new to JSON and all the talk about JavaScript templating engines for front-end dynamic changes. However, I'm struggling to make progress. Can anyone help me out? The JSON file is named data.json { users: [{ username: "alan" ...

Should we pass <script> tags or unsanitized values to the Handlebars layout?

How can I pass values to handlebars that are not sanitized upon output? For instance, I want to ensure that when using the code res.render('index', {script: '<script src="bundle.js"></script>'}), it is not rendered as {{scri ...

Frontend update: Changing the display format for dates

Received from the backend is an array of objects (leavedays)- var leavedays = [{"_id":"62d544ae9f22d","season":2022,"name":"LEAVEDAY1","dateFrom":"2022- 07-26T00:00:00.000Z","date ...

Delivering HTML files to construct a basic single page application with Node.js/Express

I am interested in developing a Single Page Application for my website. From my understanding, a SPA involves sending a single HTML file as the entry point to the application. To achieve this, I plan to use Node and Express to serve the main page, and th ...

Transitioning from Jade (PUG) to Handlebars: Solving the Problem with Loading SVG Images using Helper Functions

I have a project originally written in Pug that I am now converting to Handlebars. The issue I am encountering is that instead of loading the image, it displays markup text. This was not a problem when using Pug (Jade). To address this, I created a helpe ...

Encountering a handlebars issue when using passport-steam

I'm receiving errors and unable to display the avatar and steam name router.get('/', function(req, res) { res.render('index', { title: 'Express', user: req.user }); }); router.get('/tos', function(req, res) { res.render('tos', { title: 'Terms o ...

Why isn't the CSS outline property functioning properly within the handlebars?

I am working on a login form within a Handlebars page and I am trying to figure out how to set the default outline property to none for that particular element. Does anyone know how to do this? Snippet of code from the Handlebars file <input type=" ...

Update the nest-cli.json configuration to ensure that non-TypeScript files are included in the dist directory

I've been searching for a solution for hours now: I'm developing an email service using nestJS and nest mailer. Everything was working fine until I tried to include a template in my emails. These templates are hbs files located in src/mail/templ ...

Handlebar files are not compatible with Typescript loading capabilities

I am encountering an issue with my directory structure as follows : src |- server |- myServer.ts |- views |- myView.hbs dist |- server |- myServer.js The problem lies in the fact that the dist folder does not have a views subfolder, where the J ...

Utilizing Handlebars with Passport.js to capture user input

Currently diving into the world of node.js with passport, handlebars and mysql as my tools of choice. The goal is to design a signup page that collects email address, password, first name, and last name. However, when using passport, it only accommodates ...

How can localization be achieved in an express app using i18n + handlebars without using it to generate output HTML?

I have an Express application where I need to utilize Handlebars for creating localized email templates. The challenge here is that Handlebars necessitates a globally registered helper to translate elements within the .hbs files, while I require using a co ...

Page not found: unique error on alternate route

My website has different paths and pages in hbs format, such as root, help, and 404. The problem arises when I navigate to localhost:3000/wrong, the site displays correctly, but when I try localhost:3000/help/wrong, the CSS is not applied to the 404 page b ...

Saving JSON data into an HTML element using Handlebars templating

Is there a way to save the entire JSON object within an HTML element as a data attribute? let a = {name : "sample", age : "34"} $.find('#someDiv').data('adata', a); Is it possible to achieve the same result using Handlebars when creat ...

Utilizing JavaScript functions alongside a button within a Handlebars template

My handlebars project has the following structure: Project | +-- server.js +-- package.json +-- package-lock.json | +-- public | | | |-- css | | | + -- style.css | +-- views | | | |-- layouts | | | | | + -- main. ...

Tips for sharing common variables across all routes in Express by rendering them from app.js

Within my Node.js application, there are several variables that need to be rendered on every route. With approximately 4-5 common variables across about 20 routes, I find myself repeating the code for passing these variables in each res.render. I am seeki ...

Unable to load files in Handlebars when using Node and Express

Currently, I am in the process of developing a Node/Express web application for basic CRUD operations. However, I am encountering difficulties incorporating Handlebars into my project. Whenever I attempt to utilize Handlebars, none of the stylesheets from ...

Steps for adding a view to an element

Can someone help me with the syntax needed to append my template within the div "#draggableContainers"? I feel like I'm overlooking something simple. <html xmlns="http://www.w3.org/1999/xhtml"> New Page Title <script src="https://ajax.goog ...

Handlebars does not support loading data into variables using Express

My NodeJS/Express application utilizes Handlebars for templates, and everything works smoothly except when attempting to display data retrieved from an Express API. The data is successfully fetched and can be viewed in the Chrome debugger. In the problem ...

Tips for creating an array in a <script> tag within an hbs view template

Currently, I am delving into the world of full stack web development with a focus on Node/Express. The project at hand is to create a voting app as part of a challenge from FreeCodeCamp, which you can find here. To display user votes in pie charts on the f ...

Exploring the Possibilities of Using Multiple View Directories in Koa

In my NodeJS & Koa-views web app, I am organizing it in a modular way with the following folder structure: A/ routes/ models/ views/ B/ routes/ models/ views/ Within my Index.js file, I have the following code snippet: app.use(views(`${__dirname}/A ...

Is there a way to specifically clear the cached view for a single file in express.js?

When I render my homepage using the following code: router.get('/', function(req, res, next) { res.render('../_cache/homepage-1.hbs', { title: 'Home', style: 'home-new', projectSlug: &apo ...

Utilizing MongoDB Data in HBS Template Rendering

Attempting to showcase data from my mongodb backend on an hbs template by following this tutorial. No errors are shown in server logs or browser console, but no data is visible on the template. Interestingly, it generates HTML markup. Seeking assistance to ...

Having issues displaying the & symbol in HTML from backend data

I recently worked on a project using express handlebars, where I was fetching data from the YouTube API. However, the titles of the data contained special characters such as '# (the ' symbol) and & (the & symbol). When attempting to render the ...