Jade block refuses to render

I seem to be overlooking a small detail. Currently, I am experimenting with jade templates in express and trying to utilize blocks and extensions. However, my block does not seem to be functioning correctly. Below are the jade templates I am working with:

layout.jade

  doctype html
  html
    head
      title= title
      link(rel='stylesheet', href='/stylesheets/bootstrap.min.css')
      link(rel='stylesheet', href='/stylesheets/style.css')
      script(src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js')
      script(src='/javascripts/bootstrap.min.js')
    body
      block content

index.jade

extends layout

block content
    header
        section
            h1 Hello
            p.
                This is my first jade template
                How incredibly exciting!
    main
        div(class="row")
            div(class="col-md-6")
                block colOne
            div(class="col-md-6")
                block colTwo

colOne.jade

extends index

block colOne
    section
        p.
            this will be col one

colTwo.jade

extends index

block colTwo
    section
        p.
            this will be the second col.

While index.jade successfully extends layout.jade, colOne and colTwo are not getting rendered.

I have attempted setting my view options to {layout: false}, but it hasn't made any difference.

The router simply directs to the index.jade file:

router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express Mon'});
});

I read that I should render the lowest in the chain, which is why I render index and not layout. Does this mean I need to res.render('colOne')? I tried that, and while I got my index and layout pages, colOne still didn't show up. How would this work for colTwo?

**Lastly, my bootstrap columns don't appear to be functioning... well, at least until I realized that my Chrome inspector was opened too wide. Front end dev struggles...

Where am I going wrong?

Answer №1

To start off, my first suggestion would be to add jQuery before the Bootstrap JS file. Moving on, it seems like you are trying to render colOne and Coltwo into the col-md-6 divs of index. In order to achieve this, there is no need to extend index in colOne and colTwo as that would mean adding index to colOne and not the other way around.

The correct approach should be: index.jade

main
        div(class="row")
            div(class="col-md-6")
                include colOne //include ../folder/filename.jade
            div(class="col-md-6")
                include colTwo

In colOne and colTwo.jade, remove

extends index.jade

I hope this explanation clears things up for you.

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

Is there an alternative to @bittrance/azure-function-express that supports the newest node versions?

I recently utilized the azure-function-express package, specifically the @bittrance/azure-function-express version, to establish a connection between an Express application and an Azure Function handler. This allowed for seamless integration of all familia ...

The NodeJS/nextJS application is experiencing difficulties running on a Windows operating system

I am currently building a nextJS app on my macOS system. After executing the npm install command, I transferred all the files to a Windows 10 machine, which unfortunately does not have an internet connection. To my surprise, when running npm run dev, it is ...

Troubleshooting the non-functional asynchronous function

After starting to use redis with node (specifically the node_redis module), I decided to wrap my retrieval code for debugging and DRY principles. However, I encountered an issue where my new function wasn't working as expected. As someone who is stil ...

Incorporate relationships while inserting data using Sequelize

vegetable.js ... var Vegetable = sequelize.define('Vegetable', { recipeId: { allowNull: false, ... }, name: { ... }, }); Vegetable.association = models => { Vegetable.belongsTo(models.Recipe); }; ... recipe.js ... var Recipe = sequeliz ...

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 ...

When initiating the Grunt Express Server, it prompts an issue: Error: ENOENT - the file or directory 'static/test.json' cannot be found

I'm currently in the process of updating my app to utilize the Express Node.js library. As part of this update, I have made changes to my Grunt.js tasks to incorporate the grunt-express-server package. However, after running the server successfully, I ...

Mongoose: The Model.aggregate function is returning an array with no elements

I'm currently working on a task to determine the average value using the user's review rating for a specific product. Here are my Schemas: const journalSchema = new mongoose.Schema({ title: String, category: String, subcategory: String, ...

Retrieve an array of data from Sequelize without any wrapping objects

Hello, I am facing an issue with the query from Sequelize that I have below. models.ProviderZoneCity.findAll({ attributes: ['zoneId'], raw : true, where : { status : 1 ...

An issue was encountered with initializing digital envelope routines on a Vue.Js Project, error code 03000086

I'm encountering an issue with my Vue Project when I try to execute "npm run serve/build" syntax in the terminal. My npm node version is currently v18.12.0 (with npm 8.19.2) The error message being displayed is: opensslErrorStack: [ 'error:03 ...

The authorization header for jwt is absent

Once the user is logged in, a jwt token is assigned to them. Then, my middleware attempts to validate the token by retrieving the authorization header, but it does not exist. When I try to display the request header by printing it out, it shows as undefine ...

The webpack-concat-text-plugin "node" is not compatible

The concat-text-webpack-plugin is located deep within a package, and it throws errors when I have NextJS and Node 18. Error: The engine "node" is incompatible with this module. Expected version ">=8 <=16". Got "18.16.0" Error Found incompatible modul ...

Compiling the library with node-gyp and its dependencies

I am searching for a method to simplify the setup process for the Node.js module "libtorrent." My objective is to offer pre-compiled .node files for various architectures, similar to what is done in the fibers module. This approach allows users to instal ...

Guide to setting up node.js version 12

Attempting to upgrade to nodejs version 12 using the following command: curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash However, despite running the command, it seems that only version 8 of nodejs is still installed and npm is not present as ...

"Utilizing mongoose to perform a full join on arrays within MongoDB

I am trying to perform a 'join' on two collections. The first one is referred to as parent. The second one is known as child. This is the structure of the parent object: { "_id": "id_123" "name": " ...

What steps should I take to resolve issues with the npm installation on Linux?

I'm encountering an issue while attempting to use npm install in order to install a package. Despite my attempts to update and re-download from the root directory, I am unable to resolve the error. hackathonday1-2 git:(save-button) ✗ npm install f ...

The issue of absolute path import not functioning in NextJs

I set up a file named jsconfig.json in my route: { "compilerOptions": { "baseUrl": "." } } My nextjs version is up to date with "next": "latest" Currently, when importing components, I have to use ...

What is the process for removing a package that was installed with npm link?

After using the command sudo npm link to install a node package in its directory, how can I properly uninstall the package once my development work is complete? By running npm link, the package gets installed as a symbolic link in the system's global ...

Mixing success and error states can lead to confusion when using jQuery and Express together

I've been struggling with a simple question that's been on my mind for quite some time. Despite my searches, I haven't found a similar query, so I apologize if it seems too basic or repetitive. The scenario involves an API route (Express-ba ...

When attempting to install packages using npm init, Npm encounters errors and is

I encountered an error while attempting to install Next.js using the following command: $c:/Desktop/next: npm init next-app nextjs-blog The error message I received was: npm ERR! Could not install from "Dahal\AppData\Roaming\npm-cache&bs ...

The compatibility between Node.js and Git seems to be lacking

I'm attempting to set up automatic deployment with GitHub. I have created a JavaScript file to act as a "server" to receive the hook from GitHub, and that part is working flawlessly. However, I'm struggling with getting my hook.sh script to execu ...