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

  • Home
  • SEARCH
  • 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 7092665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:20:34+00:00 2026-05-28T08:20:34+00:00

I am trying to get plate template engine to work with express.js. My initial

  • 0

I am trying to get plate template engine to work with express.js. My initial attempt was this:

app.register('.html', {
    compile: function (str, options) {
        var template = new plate.Template(str);
        return function(locals) {
            return template.render(locals, function(err, data) {
                return data;
            });
        }
    }
});

I see that the problem is that template.render doesn’t return anything (undefined) but passes the data to a callback. I’m not sure how to make it work in this case as Express expects the compile function to return a function that directly returns a rendered template when called.

I was thinking perhaps I can use promises to solve this issue but had no success there either since the express code doesn’t expect a promise to be returned. Im not too up to speed on promises so I may just be doing it wrong:

app.register('.html', {
    compile: function (str, options) {
        var promise = new Promise();
        var template = new plate.Template(str);
        return function(locals) {
            template.render(locals, function(err, data) {
                promise.resolve(data);
            });
            return promise;
        }
    }
});

Here is an example of a custom implementation that does works. The difference is that underscore templates template() function directly returns the rendered string like so:

app.register('.html', {
    compile: function (str, options) {
        var template = _.template(str);
        return function (locals) {
            return template(locals);
        };
    }
});

I’d really like to use Plate templates since the {% block %} tag is so awesome. Any help is appreciated.

pertinent documentation:

plate’s github docs

express.js app.register docs

  • 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-28T08:20:34+00:00Added an answer on May 28, 2026 at 8:20 am

    The creator of plate promptly added a patch to the project to make it compatible with express after I asked this. plate@0.0.13+ has the change and you can see implementation details here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
Trying to get my css / C# functions to look like this: body {
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
Trying to get a JSON output to work with jqGrid 'userdata' option. The example
I am trying to get a button on my app go to the market
I am trying to get in place editing working but I am running into
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get an ASP application deployed; it worked for a while but then
Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
Trying to get comfortable with jQuery and I have encountered some sample code that

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.