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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:43:47+00:00 2026-06-14T20:43:47+00:00

I am creating this template: <% include head %> <Placemark> <name><%=name%></name> <description><%=description%></description> <Point> <coordinates><%=coordinates%></coordinates>

  • 0

I am creating this template:

<% include head %>
<Placemark>
    <name><%=name%></name>
    <description><%=description%></description>
    <Point>
        <coordinates><%=coordinates%></coordinates>
        </Point>
</Placemark>
<% include foot %>

But I always get this error:

if (!filename) throw new Error('filename option is required for includ
                         ^

Directories:

justas@justas-Studio-1555:~/node-socket.io/socket.io/examples/kml$ ls -1
app.js
foot.ejs
head.ejs
placemark.ejs

Can someone help, I according to toolbox everything should work

app.js:

var http = require('http');
var ejs = require('ejs');

var fs = require('fs')

http.createServer(function (req, res) {

res.writeHead(200, {'Content-Type': 'text/xml'});

fs.readFile('placemark.ejs', 'utf8', function (err, template) {

var content = ejs.render(template,{
    name:"test name",
    description:"this is the description",
    coordinates:"-122.0822035425683,37.42228990140251,0"
});

res.write(content);
res.end()
});
}).listen(8000);
console.log('Server listening at at xxxxxxxx');

using ejs I render template, which constructs from other templates. Using ejs-locals it says that it has no method render. Is there any way to do this with only ‘ejs’ ??

  • 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-14T20:43:48+00:00Added an answer on June 14, 2026 at 8:43 pm

    Here is a working example:

    It appears you need to pass in the filename of the template, in order to be able to use include – See example here

    var http = require('http');
    var ejs = require('ejs');
    
    var fs = require('fs');
    
    http.createServer(function (req, res) {
    
    res.writeHead(200, {'Content-Type': 'text/xml'});
    
    fs.readFile('placemark.ejs', 'utf8', function (err, template) {
    
    var content = ejs.render(template,{
        name:"test name",
        description:"this is the description",
        coordinates:"-122.0822035425683,37.42228990140251,0",
        filename: __dirname + '/placemark.ejs'
    });
    
    res.write(content);
    res.end()
    });
    }).listen(8000);
    console.log('Server listening at at xxxxxxxx');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a custom control. I want the template for this control to
I have referred this for creating error message tool tips, to be displayed continuously
I am creating first twitter bootstrap application but getting following error in rails 3.2.3
So i have been creating this framework thing that basically puts together source code
I am creating this link tag: <link rel=canonical href=<%= request.url %> /> The problem
I had a huge file for creating this GUI and I have shortened it
Seems I've outdone myself. All the while I was creating this pretty little 'latest
Why is this creating a new row at the bottom with this data instead
nobody loved my first question about this: Creating Entity Framework objects with Unity for
I am creating table like this: CREATE TABLE foobar (id uniqueidentifier, foo text, bar

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.