Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3626698
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:47:42+00:00 2026-05-18T23:47:42+00:00

I have a basic Express server: // server.js: var Express = require(‘express’); app =

  • 0

I have a basic Express server:

// server.js:
var Express = require('express');
app = Express.createServer();
app.configure(function(){
  app.set('views', Path.join(__dirname, 'views'));
  app.set('view engine', 'jade');
  app.set('view options');
});
app.get('/', function (request, response) {
  response.render('welcome', {
    locals: {some: 'Locals'}
  });
});

With a basic jade layout:

// views/layout.jade:
!!! 5
html(lang='en')
  head
    title= pageTitle
  body
    h1= pageTitle
    aside(id="sidebar")= sidebarContent
    #content
      #{body}

And a simple page:

# views/welcome.jade:
// How do I pass pageTitle and sidebarContent out to the layout from here?
p
  Welcome to my fine site!

(In Rails, this might be something like content_for or a simple instance variable.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T23:47:43+00:00Added an answer on May 18, 2026 at 11:47 pm

    Using the tip above about dynamicHelpers, and the magic of closures, I found a fairly elegant solution that works without involving the request object. The trick is to wrap the page title variable in a closure that provides a get() and set() function around it, and make that wrapper object the result of the page_title dynamic helper.

    Create a property.js:

    exports.create = function () {
        var value = null;
        return {
            get: function () {
               return value;
            },
            set: function (new_value) {
               value = new_value;
            }
        };
    }
    

    So calling create() returns an object with a get() and set() method on it, that get and set the closure variable.

    Then, in your app’s setup code:

        var property = require("./property.js");
        app.dynamicHelpers ({
            page_title: function () {
             return property.create ();
            }
        });
    

    Since the dynamic helper’s value is the result of calling its function, in your view and template, the page_title variable will be the wrapper object with the get() and set() functions.

    In your view, you can then say:

    - page_title.set ("my specific page title");
    

    And in your layout:

    title= page_title.get()
    

    To simplify this a bit further, adding this to property.js:

    exports.creator = function () {
        return function () {
            return exports.create();
        };
    }
    

    Lets you simplify the dynamic helpers declaration block to this:

            var property = require("./property.js");
            app.dynamicHelpers ({
                page_title: property.creator()
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basic Question - I have installed SQL Server Express 2008 with integrated SP1 .
I'm using node, express and connect for a simple app and have basic HTTP
I'm using Visual Basic 2010 Express. I have a form that can be minimized.
i am very beginner in visual basic and i have 2010 express. i want
I have Visual Studio web developer Addison , Visual Basic 2005 Express Edition, Visual
A very basic question. I have just installed Visual Studio 2008 Express Edition and
Hey everyone. I have a question. I am working on Visual Basic Express and
I working working with Visual Basic 2010 Express. I have a DataGridView that is
I am using Microsoft Visual Basic 2010 Express. I have a WPF-based project. I
There it is! A BUG in Visual Basic Express 2010: I have several ToolStrip

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.