Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35914 > unrolled thread
| Started by | groovee@cyberdude.com |
|---|---|
| First post | 2018-12-21 01:24 -0800 |
| Last post | 2018-12-22 20:03 +0100 |
| Articles | 10 — 8 participants |
Back to article view | Back to comp.lang.javascript
Laying out node.js like PHP..? groovee@cyberdude.com - 2018-12-21 01:24 -0800
Re: Laying out node.js like PHP..? JJ <jj4public@vfemail.net> - 2018-12-22 05:44 +0700
Re: Laying out node.js like PHP..? Luuk <luuk@invalid.lan> - 2018-12-22 10:32 +0100
Re: Laying out node.js like PHP..? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-12-22 12:40 +0100
Re: Laying out node.js like PHP..? rbowman <bowman@montana.com> - 2018-12-22 11:58 -0700
Re: Laying out node.js like PHP..? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-12-22 20:16 +0100
Re: Laying out node.js like PHP..? Ram Tobolski <ramtob@gmail.com> - 2018-12-23 02:22 -0800
Re: Laying out node.js like PHP..? Julio Di Egidio <julio@diegidio.name> - 2018-12-23 05:40 -0800
Re: Laying out node.js like PHP..? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-12-25 00:02 +0100
Re: Laying out node.js like PHP..? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-12-22 20:03 +0100
| From | groovee@cyberdude.com |
|---|---|
| Date | 2018-12-21 01:24 -0800 |
| Subject | Laying out node.js like PHP..? |
| Message-ID | <bcd9af5a-c8ed-469b-ae91-edaa5bdef6b5@googlegroups.com> |
I'm just starting to find about node.js and server side JS, so I was wondering - you know, in PHP, when you want to start writing some PHP in the HTML, you put a "<? php" in the code, ie. it lives *inside the HTML*, and the server is smart enough to start up the PHP interpreter at the appropriate points? Is there some way to accomplish that kind of thing in node.js, ie. MIX node.js and HTML in one document??? I'm probably talking rubbish, but - is there some way? :) (Hell of a hard time having the JS program keep on spitting out HTML in console.log statements otherwise (or however it's done...?!)). Thanks.
[toc] | [next] | [standalone]
| From | JJ <jj4public@vfemail.net> |
|---|---|
| Date | 2018-12-22 05:44 +0700 |
| Message-ID | <17mzlt13e4wyt.3hahuzc9ws0r.dlg@40tude.net> |
| In reply to | #35914 |
On Fri, 21 Dec 2018 01:24:44 -0800 (PST), groovee@cyberdude.com wrote: > I'm just starting to find about node.js and server side JS, so I was > wondering - you know, in PHP, when you want to start writing some PHP in > the HTML, you put a "<? php" in the code, ie. it lives *inside the HTML*, > and the server is smart enough to start up the PHP interpreter at the > appropriate points? Is there some way to accomplish that kind of thing in > node.js, ie. MIX node.js and HTML in one document??? I'm probably talking > rubbish, but - is there some way? :) I'm pretty sure there are already Node.js modules for that. e.g. instead of "<? php", it'd be something like "<? nodejs>". > (Hell of a hard time having the JS > program keep on spitting out HTML in console.log statements otherwise (or > however it's done...?!)). Node.js is a server script. It doesn't have a `console` object.
[toc] | [prev] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2018-12-22 10:32 +0100 |
| Message-ID | <5c1e04a5$0$22337$e4fe514c@news.xs4all.nl> |
| In reply to | #35921 |
On 21-12-2018 23:44, JJ wrote: > Node.js is a server script. It doesn't have a `console` object. what is this piece of doc than describing? https://nodejs.org/api/console.html
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2018-12-22 12:40 +0100 |
| Message-ID | <XnsA9C080E4EF78Eeejj99@194.109.6.166> |
| In reply to | #35924 |
Luuk <luuk@invalid.lan> wrote on 22 Dec 2018 in comp.lang.javascript: > On 21-12-2018 23:44, JJ wrote: >> Node.js is a server script. It doesn't have a `console` object. > > what is this piece of doc than describing? > > https://nodejs.org/api/console.html I would like to offer some consolidated consolation here: <https://www.tutorialspoint.com/execute_nodejs_online.php> -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | rbowman <bowman@montana.com> |
|---|---|
| Date | 2018-12-22 11:58 -0700 |
| Message-ID | <g87fopF706dU1@mid.individual.net> |
| In reply to | #35924 |
On 12/22/2018 02:32 AM, Luuk wrote: > On 21-12-2018 23:44, JJ wrote: >> Node.js is a server script. It doesn't have a `console` object. > > what is this piece of doc than describing? > > https://nodejs.org/api/console.html > I think the OP is confused between the node executable, the server side script that it runs, which isn't usually called node.js although I suppose you could, and the various approaches to serving up dynamic pages. I prefer Express and Handlebars but I'm old school. Be nice to know what he's trying to do.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2018-12-22 20:16 +0100 |
| Message-ID | <275eb02a-36bd-eca0-0724-438c30b6ffbc@PointedEars.de> |
| In reply to | #35928 |
rbowman wrote: > On 12/22/2018 02:32 AM, Luuk wrote: >> On 21-12-2018 23:44, JJ wrote: >>> Node.js is a server script. It doesn't have a `console` object. >> what is this piece of doc than describing? >> >> https://nodejs.org/api/console.html > > I think the OP is confused between the node executable, the server side > script that it runs, which isn't usually called node.js although I > suppose you could, and the various approaches to serving up dynamic > pages. I prefer Express and Handlebars but I'm old school. > […] The same as ECMAScript is NOT limited to the client side (evidence: Node.js), PHP is NOT limited to the server side (evidence: Composer), and Node.js is NOT limited to the server side (evidence: npm). I find it rather difficult to name a programming language or framework that can be used *only* either client-side or server-side. People who are saying otherwise usually have no clue what they are talking about. -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Ram Tobolski <ramtob@gmail.com> |
|---|---|
| Date | 2018-12-23 02:22 -0800 |
| Message-ID | <592ce701-f031-4499-8057-be8c21a29e34@googlegroups.com> |
| In reply to | #35930 |
On Saturday, December 22, 2018 at 9:16:40 PM UTC+2, Thomas 'PointedEars' Lahn wrote: > rbowman wrote: > > On 12/22/2018 02:32 AM, Luuk wrote: > >> On 21-12-2018 23:44, JJ wrote: > >>> Node.js is a server script. It doesn't have a `console` object. > >> what is this piece of doc than describing? > >> > >> https://nodejs.org/api/console.html > > > > I think the OP is confused between the node executable, the server side > > script that it runs, which isn't usually called node.js although I > > suppose you could, and the various approaches to serving up dynamic > > pages. I prefer Express and Handlebars but I'm old school. > > […] > > The same as ECMAScript is NOT limited to the client side (evidence: > Node.js), PHP is NOT limited to the server side (evidence: Composer), > and Node.js is NOT limited to the server side (evidence: npm). By node.js in the client side I suppose you mean for tooling, for developers, not for the end-user?
[toc] | [prev] | [next] | [standalone]
| From | Julio Di Egidio <julio@diegidio.name> |
|---|---|
| Date | 2018-12-23 05:40 -0800 |
| Message-ID | <eadd5afc-5b66-4034-9ae0-21b08f7f353a@googlegroups.com> |
| In reply to | #35931 |
On Sunday, 23 December 2018 11:42:26 UTC+1, Ram Tobolski wrote: > On Saturday, December 22, 2018 at 9:16:40 PM UTC+2, Thomas 'PointedEars' Lahn wrote: > > rbowman wrote: <snip> > > > I think the OP is confused between the node executable, the server side > > > script that it runs, which isn't usually called node.js although I > > > suppose you could, and the various approaches to serving up dynamic > > > pages. I prefer Express and Handlebars but I'm old school. > > > […] > > > > The same as ECMAScript is NOT limited to the client side (evidence: > > Node.js), PHP is NOT limited to the server side (evidence: Composer), > > and Node.js is NOT limited to the server side (evidence: npm). > > By node.js in the client side I suppose you mean for tooling, for developers, > not for the end-user? npm for gulp, grunt and whatnot: indeed, JS is becoming ubiquitous across the development toolchain, arguably the new de facto standard for platform independent scripting. It's still all on top of Node.js, running locally. Also don't forget the cross-compilers, from JS to various targets... Julio
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2018-12-25 00:02 +0100 |
| Message-ID | <7b96c9e9-f30f-51ee-f5fe-a56de209a7f5@PointedEars.de> |
| In reply to | #35931 |
Ram Tobolski wrote: > On Saturday, December 22, 2018 at 9:16:40 PM UTC+2, Thomas 'PointedEars' Lahn wrote: >> The same as ECMAScript is NOT limited to the client side (evidence: >> Node.js), PHP is NOT limited to the server side (evidence: Composer), >> and Node.js is NOT limited to the server side (evidence: npm). > > By node.js in the client side I suppose you mean for tooling, for developers, not for the end-user? Not necessarily. Consider, e.g., the Electron framework: <https://en.wikipedia.org/wiki/Electron_(software_framework)> -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2018-12-22 20:03 +0100 |
| Message-ID | <1b945279-704c-752a-786e-122ab2ec20b5@PointedEars.de> |
| In reply to | #35921 |
JJ wrote:
> On Fri, 21 Dec 2018 01:24:44 -0800 (PST), groovee@cyberdude.com wrote:
>> I'm just starting to find about node.js and server side JS, so I was
>> wondering - you know, in PHP, when you want to start writing some PHP in
>> the HTML, you put a "<? php" in the code, ie. it lives *inside the HTML*,
>> and the server is smart enough to start up the PHP interpreter at the
>> appropriate points? Is there some way to accomplish that kind of thing in
>> node.js, ie. MIX node.js and HTML in one document??? I'm probably talking
>> rubbish, but - is there some way? :)
>
> I'm pretty sure there are already Node.js modules for that. e.g. instead of
> "<? php", it'd be something like "<? nodejs>".
Utter nonsense.
It is written “<?php” and of course one does not write “<? nodejs” or
anything similar.
Because PHP does NOT "live inside the HTML". It is the *P*HP *H*ypertext
*P*reprocessor: It *generates* output *along* with HTML (or anything else)
which it does not parse (outside “<?php … ?>” or “<?= … ?>” [PHP 5.4+
default only] sections):
<http://php.net/manual/en/tutorial.firstpage.php>
Also, PHP is NOT limited to server-side use.
As it regards to Web development, Node.js uses a completely different
approach: It generates everything from Google V8 JavaScript code.
So it may process and fill *external* templates.
However, there are ways with Node.js so that you do not have to write HTML
yourself. One of those ways is Jade, now Pug; I have used it professionally
for about two years. The neat thing about Jade/Pug is that it is triggered
by JavaScript (sic!), but you can also use JavaScript in the templates. So
you can write a table as a “for” loop or (better) a for-each loop (AFAIK
only available natively in Jade/Pug):
table.table
each value, index in ['foo', 'bar', 'baz']
tr.table-row
th.table-data: =index
td.table-data: =value
<http://jade-lang.com/>
You can test it e.g. with <https://codepen.io/> if you set the HTML
Preprocessor to “Pug”. You can use <https://codepen.io/Mildwind/pen/rOebvr>
as a starting point. Note that indentation carries semantics in this
templating language.
>> (Hell of a hard time having the JS program keep on spitting out HTML
>> in console.log statements otherwise (or however it's done...?!)).
>
> Node.js is a server script. It doesn't have a `console` object.
Utter nonsense.
In my work for a subsidiary of one of the largest Swiss media companies
(global player), we have used Node.js *client-side* to generate HTML and
source-mapped CSS (from Jade templates and LESS files), and minified,
source-mapped, browser-compatible ECMAScript, and to update the browser(s)
when the sources change (Gruntfile.js triggering npm, jade, node-less and
browser-sync).
We have occasionally used console.log() for debugging Node.js code
as *it is a Node.js built-in*:
<https://nodejs.org/api/console.html>
The server-side code was written in C# and used ASP.NET templates.
Many people, including me, are using npm (Node.js Package Manager) and npm
packages to support their local development environment and remote deployment.
In my new work we are using it to build minified, source-mapped,
browser-compatible ECMAScript code from (browser-incompatible) ES 6+ code,
and source-mapped CSS from SCSS files, automatically when the sources change
(a package.json triggering watch triggering babel and node-sass).
The server-side code is written (in part by me) in PHP and Python. The PHP
code so far either uses included PHP templates or Twig templates.
PointedEars (ZCE PHP)
--
Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web