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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:11:49+00:00 2026-05-24T13:11:49+00:00

I set up a node.couchapp.js CouchApp and pushed it to my CouchDB. There is

  • 0

I set up a node.couchapp.js CouchApp and pushed it to my CouchDB. There is Sammy and jQuery included by default. Now, I’d like to add Mustache for templates, but don’t exactly know where? I could use it as Node.js module or jQuery plugin.

I started with some sample code, just to see if it works, but it doesn’t:

ddoc.lists = {
"basic": "function (head, req) { var that = this; provides('html', function () { var to_html = require('modules/mustache').to_html; var members = []; var row; while (row = getRow()) { members.push({club: row.key[0], name: row.key[1]}); } return to_html(that.templates['roster.mustache'], { members: members }); }) }"
};

Results in:

{"error":"invalid_require_path","reason":"Object has no property \"modules\". ...

Project structure is:

. Project
| - app.js
| - attachments
| - - scripts
| ` - index.html
| - modules
|   | mustache
| - ` - mustache.js
` - templates

Update
I modified the code a bit and excluded the template folder as possible cause. This snippet is from a solved question here on SO, so it should actually work. But it’s still the same error. I installed mustache.js with npm install mustache and renamed the folder from node_modules to modules (didn’t work with node_modules either).

"basic": "function (head, req) { provides('html', function () { var template = '{{%IMPLICIT-ITERATOR}}{{name}}: <ul> {{#items}}<li>{{.}}</li>{{/items}} </ul>'; var mustache = require('./modules/mustache/mustache.js'); return mustache.to_html(template,view);});}"

But it’s still the same error.

  • 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-24T13:11:51+00:00Added an answer on May 24, 2026 at 1:11 pm

    I’m not sure about the specific error you’re getting, but to your question:
    “Now, I’d like to add Mustache for templates, but don’t exactly know where? I could use it as Node.js module or jQuery plugin.”

    You can use it in both.

    As Node.js runs on the server-side this effectively gives you a way to define your template once (using Mustache in this case) and run it both server-side (using Node.js) and client-side (using the jquery-plugin).

    Just for the overview (you may well already know this):
    Imagine rendering a search-result of products:

    • The traditional way is to render the products with some server-side templating engine.
    • Now, let’s say you want to enable filtering / sorting of the search-results. Generally speaking you have 3 options:

      1. do a normal (non-ajax call) to the server, do server-side templating and spit out the new page
      2. do an ajax-call to the server, do server-side templating and spit out html, pick it up client-side and insert it into a dom-element.
      3. do an ajax-call to the server, generate a json-object, which you render client-side using a client-side templating engine (such as Mustache) into a dom-element.

    Option 3 is arguably the best solution from a usability standpoint. (quick, low-bandwidth, no page flickering or page jumping, etc. ) . However think about a fallback/non-js way for SEO if you need it.

    When implementing option 3 however you now have the situation of needing a server-side templating language to render products on the initial page load, and a client-side templating language to render products returned from subsequent ajax-calls. Both result in the exact same html. Not very DRY.

    Here node.js comes into play, which eliminates the need for writing a seperate server-side template. Instead, just let node.js spit out the initial page using the exact same mustache template you use on the client-side.

    Of course you could go the only client-side route: spitting out json on the intial page load as well, and render that on the client. This of course if terrible from a seo-standpoint. Some apps don’t the search engine indexing however, in which case the ‘everything on the client’ approach is a good alternative.

    Some related questions:

    • Client-side templating language with java compiler as well (DRY templating)
    • Good DRY approach to rendering and AJAX updating of page
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to remove a node by index now. I'd like to print out the
I have a group of lines like the following: tb-set-node-recipe $vpn1 W2K3_SP2_VPN_SRV tb-set-node-os $vpn2
I have a HTML string that I convert to a JQuery node set: var
<% Set xmlDoc = Server.CreateObject(MSXML2.DOMDOCUMENT) xmlDoc.loadXML( <response /> ) Set node = xmlDoc.createElement(account) xmlDoc.documentElement.AppendChild
I am having a real headache trying to set a node's local position to
In XLST how would you find out the length of a node-set?
I have parent/child relationship set up via Node Reference. A Child record can have
I try to set an attribute in a XML node using MSXML. IXMLDOMElement alone
I have a tree structure where each Node has a parent and a Set<Node>
I have node set with header, leading, body text etc... I want to make

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.