Questions tagged [ejs]

Incorporated" starts with "I." EJS stands for Easy JavaScript Templating, a straightforward framework for creating HTML code using plain JavaScript. No dogmatic rules on structuring content. No need to recreate loops and control statements. It's simply pure JavaScript.

Creating dynamic content with Express.js: Using variables in EJS within the request handler

I am looking for a way to include additional variables to be utilized by EJS during the rendering of a view for every request, similar to adding them in the render function: res.render('view', {data: {my: 'object'}}); I have implement ...

Problem with deleting or substituting symbols and character codes within a String

I am attempting to send an object called dataO from Node.js/Express/EJS to the client side. On the Node.js script side: var dataO = {"first":[20000, 14000, 12000, 15000, 18000, 19000, 22000], "second":[12000, 11000, 18000, 12000, 19000, 14000, 26000]}; var ...

Creating a connection between my .html and .ejs files: A step-by-step guide

I have successfully created a pair of HTML files - index.html & contact.html. Within these files, I have implemented a navigation bar that allows for seamless transition between them. Recently, I delved into the realm of retrieving APIs and crafted an app ...

Strip the URL prefixes to access files in the public directory easily

Despite creating a static public folder in app.js, When I visit "http://localhost:3000/calendars/add", the styles from the public folder are not applied. This is because Express has appended "calendars/add/" to the public folder URL. As a result, it appe ...

Guide to iterating within a loop with a variable number of iterations above or below the specified amount in JavaScript

I am currently engaged in a project for a small theater group, and I am facing challenges with getting this loop to execute properly. <% include ../partials/header %> <div class="jumbotron jumbotron-fluid"> <div class="container"> ...

Transmitting information to the service array through relentless perseverance

I need assistance finding a solution to my question. Can my friends help me out? What types of requests do I receive: facebook, linkedin, reddit I want to simplify my code and avoid writing lengthy blocks. How can I create a check loop to send the same ...

The function call app.set('views', viewsPath) in EJS does not seem to be functioning as expected

Software Dependencies: "ejs": "^3.1.9", "express": "^4.18.2", The structure of my project directory is as follows: /usr/src/app/ | |- app.js |- api/routers/main.js |- website |- src/views/myView.ejs |- r ...

EJS rendering with a for loop

I have a node server sending three arrays to my .ejs page and I want the display to look like this: Image But currently, it looks like this: Image Below is the code snippet: <div class="webvUI-panel__bd"> <a href="javascript:void(0);" class= ...

Uploading data using NodeJS and EJS

Currently, I am utilizing NodeJS/Express and EJS to develop a form for an API route. However, when attempting a POST request and accessing req.body.password & req.body.confirm, I consistently receive "undefined" as the response. index.js import http from ...

Incorporate a PDF into an .ejs file

I'm facing an issue with my web app that involves the use of express.js. I attempted to embed a pdf file within a .ejs file by using the following code snippet: embed src="mypdf.pdf" width="500" height="375" /> Upon loading the page, I encountered the ...

What is the best way to retrieve the document DOM object within an EJS template?

I am attempting to display a list of participants when the user clicks on the button. However, every time I try, I encounter an error stating "document is not defined". (Please refrain from suggesting the use of jQuery!). <% var btn = document.getEle ...

Creating dynamic databases in real-time with Node, EJS, and Firebase

As I venture into learning Node JS, I am currently transitioning from a client-side chat application to a server-side one. Previously, when my app was solely client-side, any modifications to the database automatically triggered data reload in a div, provi ...

Having trouble getting Node.js, express, socket.io, and ejs to work together?

Currently, I am working on improving my knowledge of java-script and had the idea to create a basic chat app using Express, stock.io, and ejs. Unfortunately, I am facing some challenges in getting it up and running smoothly. Below is the snippet from my ...

Using Filepond to upload images in an Express project with EJS integration

Currently, I am working on a project that utilizes express.js for backend functionality and ejs as the rendering template for frontend. As part of this project, I have uploaded some images using filepond which were then converted to base64 format. However, ...

Why is it that instead of a callback, I am receiving an [Object Promise]?

I am facing an issue while setting up a registration page with express-validator. After upgrading the middleware to version 6.2, I started receiving an error when trying to run my app. It seems to be related to the Validator section, as it was working fine ...

Issues with saving data to MongoDB using NodeJS, ExpressJS, and EJS database connection

I am in the process of developing a childcare management web application using NodeJS with ExpressJS, mongoose, and EJS. The application features a module for adding participants and another module to track each participant's daily meal count four tim ...

How to send multiple collections to a view using Express and Mongoose

I've encountered an issue while trying to pass multiple mongoDB queries to my EJS view using the code below. Surprisingly, only the "mvl" query is getting passed down successfully. The "extras" query seems to be unavailable as none of its values show up on ...

Retrieve the information following a redirection

There is a page '/order/new' with 2 dropdown menus for customer and their address, along with a button that redirects to choose products to add to the order. The selected products are saved in an array called 'hh' which receives data from an AJAX call. How ...

What could be causing the malfunction in this JavaScript and WebRTC code?

<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>Vid Chat App</title> </head> <body> <video controls autoplay> </video> <script src="https: ...

What is the best method for displaying the index page in node.js using ejs-templating instead of traditional express.static content?

When using a restaurant food menu generator, I am able to view it with HTML by utilizing the following code: app.get('/', function (req, res) { res.sendFile(__dirname + '/views/index.html'); }); This method uses express static. Bu ...

Setting up Browser Sync, EJS, Gulp, and Node for a seamless workflow

I am currently working in a Node environment and using gulp for SASS, EJS for templates. I'm also trying to incorporate Browser Sync into my setup but running into some configuration issues with my gulp file. When I run 'node server.js', my app loads in th ...

Is there a way to transfer a document from Node.js to an EJS template?

I am looking to retrieve a specific file and pass it to an embedded JavaScript (ejs) template. Can someone guide me on how to successfully transfer the file from a node endpoint to the embedded JavaScript template? ...

Guide to Serving PDF Files with Node, Express, and EJS

I've hit a roadblock with what I thought was a simple task. My goal is to create a link that will open a PDF file in a new tab, rather than automatically downloading it. Just to clarify, I already have the PDF file ready and saved. Here's a snip ...

Encountering an 'undefined' response when passing an array in Express's res.render method

After my initial attempt at creating a basic node app, I discovered that the scraper module was working correctly as data was successfully printed in the command window. Additionally, by setting eventsArray in index.js, I confirmed that Express and Jade te ...

Error found in the HTML tag data when viewing the page source for an issue

I am displaying some data from my express to ejs in HTML tag format. It appears correctly on the ejs template page and the web page. However, when I check the page source, the HTML tags are encoded and displayed as unescaped characters. Is there a solution ...

Something went wrong trying to retrieve the compiled source code of https://deno.land/[email protected]/path/mod.ts. It seems the system is unable to locate the specified path. (os error 3)

Upon executing my main.ts script using deno, I encounter the following error message: error: Failed to retrieve compiled source code from https://deno.land/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bfcccbdbff8f918a86918f"& ...

Tips for displaying the contents of `[object Promise]` within koa2

I have a query let data = ctx.get("list.json"); ctx.set("Content-Type", "application/json"); await ctx.render('index', { somecontent:onecontent, seconddata: list }); In index.ejs <%=second ...

Retrieving form parameters within an EJS template

Hey there! I'm diving into the world of Node.js on my own and hitting a stumbling block that seems simple but is causing me some serious frustration. Despite countless searches on Google, I can't seem to figure it out due to fatigue setting in. I ...

What could be the reason for my partial.ejs not appearing on the screen?

I've been delving into learning node.js using the book "Get programming with node.js" by Jonathan Wrexler. However, I'm currently stuck on understanding how to implement partials as explained in chapter 10. In an attempt to create a navigation partial, I ...

What sets apart the CSS file directories in a React application compared to those in an Express server?

For instance, there is a public folder that contains all the css files, and a separate view folder for ejs files. When linking the css file in the ejs file, the code usually looks like this: <link rel=”stylesheet” href=”styles.css”> or like ...

The functionality of Express is limited to port 3000 only

My application is only operational on port 3000. If I attempt to switch to a different port, it functions correctly. However, upon loading a page, an error occurs: abc is not defined at eval (eval at compile (C:\Users\ASUS\node_mod ...

Guide to efficiently display data without the need to refresh the entire page in a node js application by utilizing the ejs templating

I'm just starting to learn about Node JS. Here's the code I've been working on. I'm having trouble rendering new data after an AJAX call. Is this the correct way to update data without refreshing the entire page? Is there a more efficient method to only lo ...

Issue: The error message "articales.forEach is not a function" is indicating

app.get('/', (req, res) => { const articales = { title: 'Test Articles', createdAt: Date.now(), description: "Test Description" } res.render('index', { articales : articales }) }) <div ...

The issue with EJS Header and Footer not showing up on the

I am currently building a basic todo list application using EJS. However, I am encountering an issue when running it. I would like to run app.js with the header and footer in EJS, but it seems that it is not recognizing the header despite using what I beli ...

Steps for defining local variables accessible across all EJS templates:1. Begin by creating a helper function

When setting local variables in the /login router as shown in the code snippet below: res.locals.username = data[0].username;, I have checked the output using console.log for both data[0].username and res.locals.username, and it correctly displays the user ...

Provide access to MongoDB data in a route quickly

I'm facing what appears to be a simple issue, yet struggling to locate comprehensive documentation on it. My goal is to pass JSON data from mongodb into a route for it to be accessible in my ejs template. Here is my schema: var GiveSchema = new Schema( ...

NodeJs encountered an issue due to the absence of defined username and data

I am facing an issue while trying to open the places.ejs file by clicking the submit button on the show.js page. Similar to how the show.ejs page opens upon clicking the submit button on the new.ejs file, I am encountering a reference error. Any assistance ...

The Express generator automatically generates Pug files in the view folder

While developing a web application using node.js, express, and the express generator, I noticed that the template files in the "view" folder end with .pug extensions. Shouldn't they be .ajs files instead? Is there a way to change this setting? I'm still ...

Can someone explain to me how I can customize the background of a bootstrap container?

Currently, I am working on an EJS login project and I have created a style.css file with the following code: [theme="bloodRed"] { background-color: #ff2424; color: #e571e1; accent-color: #00ff00; } In my register.ejs ...

Executing password validation on login/register form using Node.js and EJS

In order to demonstrate a simple login page, I have created a form that requests typical information like username, password, etc. Additionally, it prompts the user to confirm their password, and if the lengths do not match, an error is triggered to notify ...

"Error: 'res' variable is undefined within the EJS template

My task is to dynamically display different templates based on the route, which in this case are /edit and /new. I need a condition to determine whether to show tabs or something else. In my router.get('/edit' cb) function, I tried checking if res.url.inc ...

What is the process for developing a JSON model or schema in Express.js?

Looking to create a JSON model or schema for storing form input data on a local JSON file, I have experience with MongoDB but want to keep it simple in this project by using a basic JSON file. Is there a way to structure the data similar to a Mongoose sche ...

Learn how to effectively incorporate a file with a variable in EJS version 2

Recently, I encountered an issue while using EJS (version - 0.8.4) after making some changes to the file: node_modules/lib/ejs.js at line ~ 155 : The old code looked like this: if (0 == js.trim().indexOf('include')) { var name = js.trim().slic ...

What could be the reason why I am unable to load the ejs file?

https://i.stack.imgur.com/91bPg.png Issue: Unable to find the "index.ejs" view in the views directory ...

Having trouble with Express Get Routes - keeps showing 404 error

I am encountering an issue with my basic node express application. The root route loads fine, but additional routes such as /about or /services are not working correctly. Even though I can change the EJS template for the homepage and it renders properly, ...

Trouble with defining variables in EJS

Recently delving into the world of node development, I encountered an issue with my EJS template not rendering basic data. I have two controllers - one for general pages like home/about/contact and another specifically for posts. When navigating to /posts ...

What is the reason for the retrieval of jquery-3.5.1.min.js through the request.params.id expression?

For my school project, I am using Express.js with TypeScript to create a simple app. This router is used for the edit page of a contact list we are developing. It displays the ID of the current contact being edited in the search bar. The problem arises whe ...

Issue with a variable within an *.ejs file

Currently, I am following a guide found at this link, and everything is working smoothly except when I encounter an error on the login screen: ..... 7| >> 8| <% if (message != null) { %> 9| <%= message %> 10| <% } %> 11| message is not defined ...

Issues are arising with the for loop in an express node js app using ejs, as it is not displaying the intended data and

I am currently utilizing a for loop in JavaScript to display all the users from the database using ejs. I have included the code snippet below. This is within an express/node js application where SQL is used for data storage. <div class = "Contacts ...

Rendering EJS templates and smoothly scrolling to a specific section on a webpage

I need to display my index page and automatically scroll down to the form section. One way I thought of doing this is by: app.post('/rsvp', (req, res) => { res.render('index/#rsvp', { errors: { email: 'Your email has already been registered'}}) } Th ...

What is the best way to define a variable in EJS?

I need to populate my database array results on the frontend using EJS. The code snippet I'm using is as follows: var tags = ["<%tags%>"] <% for(var i=0; i<tags.length; i++) { %> <a href='<%= tags[i] %>'> &l ...

Issue with rendering an object's property using EJS

Trying to include the author's username in reviews within an ejs template for my app. The following code snippet: <%= review.author %> is functioning correctly and displays: { _id: 5eff6793e7f26811e848ceb1, username: 'mike', __v: 0 } However, wh ...

Store the user's login credentials securely in the browser's local storage

Currently, I am implementing user authentication in Node Express with EJS using JWT. The generated token is stored in cookies using the following code: res.cookie('authorization', token, {maxAge: 3 * 60 * 60 * 1000}); During verification, I can ...

Having trouble with the POST method in my Node.js application, and I'm unsure of the cause

This is the main index.js file that serves as the entry point for my Node.js application. const express = require('express'); const app = express(); const path = require('path'); const port = process.env.PORT || 2000; require('./db/connection'); const Logi ...

Error uploading posted object with Mongoose

Having some trouble with uploading posted data to Mongo in NodeJS. When I try the following code: var itemOne = steTodo({task: 'something', date: 'something', status: 'something' }).save(function(err) { if(err) throw err; console.log('It ...

Implementing the adding functionality within an ejs file

I'm currently working on a project that involves fetching data from an API using a simple JavaScript file upon clicking a button. Initially, everything was functioning properly when both the HTML file and JS file were in the same folder, and I could acce ...

Restrict users to submitting only one review per journal in Mongoose platform

I am currently working with three schemas: const journalSchema = new mongoose.Schema({ title: String, category: String, subcategory: String, review: [{type: mongoose.Schema.Types.ObjectId, ref: 'Review'}], link: String, description: String, s ...

Can a new EJS file be generated using the existing file as a template?

I am in the process of building a website navbar and I am curious about how to automatically inject code from one ejs file into another ejs file. In Python's Flask framework, this is accomplished using the principle of {% block title%} and in another fil ...

Sort activities according to the preferences of the user

This is the concept behind my current design. Click here to view the design When making a GET request, I retrieve data from a MongoDB database and display it on the view. Now, I aim to implement a filter functionality based on user input through a form. ...

Implement a hashtag system with Node.js and MongoDB

I have a vision for an app that allows users to tag their content using Node and MongoDB. Progressing, I successfully managed to store the tags in the database as an array: "tags": [ "laughing", "smile" ] However, I encountered an issue while tr ...

Is there a way to automatically redirect my login page back to the original page in case of login failure?

I'm currently working on a basic login page using express.js + E.js. If the login credentials are incorrect, I have a variable badLogin that is triggered (see below). However, my goal is to redirect the website back to the login page instead of remai ...

Can an ejs template be displayed without the need to refresh the page?

I'm currently developing a game server that involves players entering a game room and getting paired with another player. One feature I would like to implement is displaying the game board without having to reload the page in order to avoid reinitiali ...

Variable missing in the ExpressJs view

Hey there! I'm new to Nodejs and currently experimenting with it. I've been trying to convert some of my basic Python codes to JavaScript. In one of my projects, I am sending a get request to the YouTube API and receiving 50 results in JSON forma ...

express.static() fails to serve files from public directories when accessed via router paths other than "/"

Express static configuration: app.use(express.static(__dirname + "/public")); Directory Structure: --public --assets --js --[JavaScript scripts] --stylesheets --[CSS files] Defined Routes: const shopRoutes = require('./routes/shopRoutes' ...

Is it possible to view the frames/packets being transmitted from an EJS or HTML form to the Express backend using Express Js?

My current computer science assignment involves visually representing the data transfer process between a frontend and backend. I don't need to show the full data, just the flow of chunks and how it navigates through protocols. Could someone please guide ...