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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:21:45+00:00 2026-06-02T16:21:45+00:00

Consider e.g. the following scenario: we give some entry point URL (something like https://our.server/customer-name/entry-point.js

  • 0

Consider e.g. the following scenario: we give some entry point URL (something like https://our.server/customer-name/entry-point.js) to our customer, so that they’re able to include our product on their page by simply writing

<script language="Javascript" src="https://our.server/customer-name/entry-point.js"/>

in the place they want to put our product (yes, I know, this is an ugly solution, but it is not something I could change).

So here we face the problem: our entry-point.js should somehow know from where (https://our.server/customer-name/) it should load the other files. So it seems that the answer is to generate entry-point.js dynamically so that it will contain e.g.

var ourcompany_ourproduct_basepath = "https://our.server/customer-name/";

The obvious way to do this is to construct an entry-point.js manually, something like this:

res.write("var ourprefix_basepath = \"" + basepath.escape() + "\";");
res.write("function ourprefix_entryPoint() { /*do something*/ }");
res.write("ourprefix_entryPoint();");

As you can see, it is just too bad.

Is there any template engine that will allow e.g. for the following:

var basepath = "https://our.server/customer-name/";
var export = {
    ourprefix_basepath: basepath.escape(),
    ourprefix_entrypoint: function() { /* do something */ }
};
templateEngine.render(export);

or

view.vw:
    ourprefix_basepath = rewrite("{#basepath}");
    function ourprefix_entrypoint() { /* do something */
    ourprefix_entrypoint();

App.js:
    templateEngine.render("view.vw", { basepath: "https://our.server/customer-name/" });

or something like this (you’ve got the idea), which will write the following to the response stream:

var ourprefix_basepath = "https://our.server/customer-name/";
function ourprefix_entrypoint() { /* do something */ };
ourprefix_entrypoint();

?

  • 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-02T16:21:46+00:00Added an answer on June 2, 2026 at 4:21 pm

    It seems that Node.js supports reflection, though i can’t find if it is explicitly stated somewhere.

    So, by exploiting the fact JSON is the subset of JS, the following cleaner code without using a template engine is possible:

    var entrypoint = function(data) {
        /* do something with data.basepath and data.otherparam here... */
    }
    
    exports.processRequest = function(request, response) {
        var data = {
            basepath: computeBasepath(request),
            otherparam: "somevalue"
        };
        response.send("(" + entrypoint.toString() + ")(" + JSON.stringify(data) + ")");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider following scenario: I have RESTful URL /articles that returns list of articles user
Original Question Consider the following scenario: public abstract class Foo { public string Name
Consider the following scenario: A process on the server is used to handle data
Consider the following scenario: http://www.restserver.com/example.php returns some content that I want to work with
Consider the following scenario: Tables: Employee (EmpId(PK), Name) TeamMembers(TeamId(PK), EmpId(PK)) Project(ProjId(PK), TeamId) I really
Please consider the following scenario: VNC Client try to connect with a VNC Server
Consider the following scenario . I have an array of numbers: [ 1,2,3,4 ]
Please consider the following scenario: map(T,S*) & GetMap(); //Forward decleration map(T, S*) T2pS =
Let's consider the following scenario: a function which can generate code colors from white
consider the following code scenario: <?php //widgetfactory.class.php // define a class class WidgetFactory {

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.