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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:04:14+00:00 2026-05-22T13:04:14+00:00

In a php file I can do: <p><?php echo hello!;?></p> Is there a way

  • 0

In a php file I can do:

<p><?php echo "hello!";?></p>

Is there a way to do this in node, if yes what’s the logic for it?

I have an idea how could this be done:

  • Use an identifier markup for node in the HTML file like: <node>code</node>

  • Load & Parse HTML file in Node

  • Grab node markup from the HTML file and run it

But I’m not sure if this is the best way or even if it works 🙂

Please note I want to learn node.js, so express and other libraries and modules are not answers for me, because I want to know the logic of the process.

  • 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-22T13:04:14+00:00Added an answer on May 22, 2026 at 1:04 pm

    What your describing / asking for a node.js preprocessor. It does exist but it’s considered harmful.

    A better solution would be to use views used in express. Take a look at the screencasts.

    If you must do everything from scratch then you can write a micro templating engine.

    function render(_view, data) {
        var view = render.views[view];
        for (var key in data) {
            var value = data[key];
            view.replace("{{" + key + "}}", value);
        }
        return view;
    }
    
    render.views = {
        "someView": "<p>{{foo}}</p>"
    };
    
    http.createServer(function(req, res) {
        res.end(render("someView", {
            "foo": "bar" 
        }));
    });
    

    There are good reasons why mixing php/asp/js code directly with HTML is bad. It does not promote seperation of concerns and leads to spaghetti code. The standard method these days is templating engines like the one above.

    Want to learn more about micro templating? Read the article by J. Resig.

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

Sidebar

Related Questions

Hello I'm doing file upload with Yii. I have implemented this way and it
Let's say file test.php looks like this: <?php echo 'Hello world.'; ?> I want
To grab the inode of a file in PHP, you can use this: $fs
How can I create a simple PHP file, which will retrieve the HTML and
using Fast CGI I can't get it to read the php.ini file. See my
I'm just wondering how I can read a text file in php, I'd like
In php how can I read a text file and get each line into
How can you allow a PHP script to write to a file with high-security
How can we connect a PHP script to MS Access (.mdb) file? I tried
How can I get the name of a file in in PHP? What I

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.