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 9008357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:55:09+00:00 2026-06-16T01:55:09+00:00

In the web app I am making, I use the classical Express+Jade to render

  • 0

In the web app I am making, I use the classical Express+Jade to render client pages and also expose some REST API (let’s say : “user list API”).

These client pages use provided API to retrieve “user list” and display it. To display it, I use the handlebars template library once the data is retrieved.

It seems a bit dirty to me, using two template engines, parsing the code twice, how to make it better ?

Note : I already optimized the thing by sending the initial data within the client page by inserting it a script variable. This variable is then displayed the same way data received by API would be. The API is only used in case of data refresh.

UPDATE : using jade both server and client side is a good idea but how to seperate / specify ? Wich part of the rendered template should be done by when serving the page and what part will be used by the client ?

  • 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-06-16T01:55:10+00:00Added an answer on June 16, 2026 at 1:55 am

    That’s very easy to use Client side + Server side templating.When we are building some web apps,we should use ajax to get some data and use the callback function to deal with it.So we should render these data on the client side.

    The question is how to render them on client side?

    Now We just need a client side jade.js.

    Follow this document : https://github.com/visionmedia/jade#readme

    First

    git clone https://github.com/visionmedia/jade.git
    

    Second

    $ make jade.js ( in fact the project has already compile the file for us )
    
    so we just need to copy this file to the path that we use.
    

    Third

    read my demo below :
    
    <script type='text/javascript' language='javascript' src="lib/jquery-1.8.2.min.js"></script>
    <script type='text/javascript' language='javascript' src="lib/jade/jade.js"></script>
    <script type='template' id='test'>
    ul
      li hello world 
      li #{item}
      li #{item}
      li #{item}
    </script>
    <script>
      var compileText = $("#test").text();
      console.log( typeof( compileText ) );
      var fn = jade.compile( compileText , { layout : false } );
      var out = fn( {item : "this is item " } );
      console.log( out );
      $("body").append( out );
    </script>
    

    Now you can see the output result in the body

    hello world
    this is item
    this is item
    this is item
    

    After reading this demo I think that you would know how to seperate jade server side and client side.If you can understand which one compile the jade template,then all the questions are easy.

    Maybe you would have another question now.How to write some jade template codes in *.jade?The document also provide us a way to do it.This Tutorial may help you.

    index.jade

    !!!5
    html
      head
       title hello world
      body
        ul#list
    
        script#list-template(type='template')
          |- for( var i in data )
          |    li(class='list') \#{ data[i].name }
          |- }
    

    index.js

    /* you javascript code */
    var compileText = $('#list-template').text();
    var compile = jade.compile( compileText , { layout : false } );
    
    var data = [{ "name" : "Ben" } , {"name" : "Jack" } , {"name" : "Rose" }];
    var outputText = compile( data );
    
    $("#list").append( outputText );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a web-app that makes use of nodejs, mongodb, socket.io, express and mongoose.
I'm making a Spring MVC web-app with some RESTfull resources as an API. I
I am trying to use AJAX for a web app game that im making.
We recently built a web app using Prototype, making a fair amount of use
I have some problems with making my web-app adapted for remote user browseres language
My app is making heavy use of webservice calls. Lately, some of the calls
Im making a Web app. I want block it's selecting texts. When I use
i've been making web app's and working with various server side language like php,
I have a web app I'm making to run off a CMS that is
I'm making a web app. In it there are times when a form may

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.