@Geerten well express is just a higher abstraction level than connect and 
provides some defaults around your project, provides some handy shortcuts 
etc. version of express past 3.0 allow you to build your app in a high 
modular way as mounted apps without much work. at the end it's a matter of 
taste and use of abstraction. 

@abhi:
1. use ejs, just replace the dynamic parts with serverside js. thats the 
simplest step. or deliver just plain html (with response.sendfile() ) and 
do clientside dom manipulation with ajax-delivered data as now

2. handlebars wrapper for express https://github.com/donpark/hbs. or just 
use handlbars.js directly in plain node/connect. just install and require 
it.

3. use connect (or express) with static middleware (as @Geerten suggested), 
port your php code into js functions with the signature function(request, 
response). register the function to the apropriate route. you do not have 
to use any template engine (jade) or css transpiler (stylus).

4. dont know. i use the web, there are so many tutorials, but i doubt, 
you'll find some which covers all the topics at once.
5. at last it's more a matter of taste, again. but key advantages of jade 
are: it abstracts html into a haml-like syntax, it offers you very rich set 
of how you can separate and structure your templates: partials, mixins, 
inheritance, layouts. if you are used to do logic in templates, then jade 
is ok too, but it's not really an advantage in my opinion.

6. connect static middleware, or https://github.com/cloudhead/node-static , 
or even more such module. just search on npm
in express a simple example:

var express = require('express')
var app = express()
//serves html, js and css files from the path, automagicaly setting headers 
suitable for caching et al
app.use(express.static('path/to/your/static/files'));


Am Mittwoch, 20. Februar 2013 01:19:23 UTC+1 schrieb kanitkar...@gmail.com:
>
> Thanks a lot Gregor & Geerten for your replies !!!
>
> I have following scenarios or situations
>
>
>    1. In my projects, HTML designers create mockups in plane HTML & CSS 
>    with dummy data where dynamically generated data will be placed and HTML 
>    templates can be used by JavaScript developer later. Heavy use of CSS and 
>    complex nested Html gets created with supporting jQuery or Javascript code 
>    of jQuery plugins used sometimes. So a bit difficult to imagine doing same 
>    in Jade.
>    2. I don't know about Jade, but I am fond of HandleBars, so I want to 
>    know how to use it in Node JS project ? 
>    3. The scenario is like this ->> If I have an existing project with 
>    this technology stack ->> HTML + CSS + JS + jQuery +  PHP(only for 
> database 
>    calls and not for .php pages, php is connected to .html pages only through 
>    Ajax). And now I just want "port" this Dynamic Web App to NodeJS by 
>    replacing business logic written in PHP with Node JS and also have Node JS 
>    as http web server. So no more PHP or WAMP in picture now. How can I 
>    achieve this without Jade & Stylus ? Any pointers/ links to github repos 
> or 
>    jsFiddles are welcome.
>    4. What is an excellent ebook that I can buy which teaches how to do 
>    end to end development of HTML + CSS + jQuery + HandleBars + Backbone/ 
>    KnockoutJS + NodeJS kind of web apps without Jade
>    5. Can any one of you experienced people elaborate on what are key 
>    advantages of using Jade over HandleBars ? I just don't want to learn new 
>    thing for the sake of it without a good reason :)
>    6. How to achieve same thing mentioned in link(
>    
> http://thecodinghumanist.com/blog/archives/2011/5/6/serving-static-files-from-node-js<https://mex07a.emailsrvr.com/owa/redir.aspx?C=0XUOyGttuk-E178ujGwQ4PWeAPyW4s9Ic5T8XNiO6uB0y_vWS3p3hQueay6fxh98syLG2dS89qU.&URL=http%3a%2f%2fthecodinghumanist.com%2fblog%2farchives%2f2011%2f5%2f6%2fserving-static-files-from-node-js>)
>  
>    in a better & abstract way ? 
>    
>
> On Tuesday, February 19, 2013 11:49:13 PM UTC+5:30, Geerten van Meel wrote:
>>
>> Great, someone who doesn't want to use express! I myself find this 
>> framework too specific as well. However, there are true advantages in using 
>> existing projects instead of re-inventing the wheel. Since the node http 
>> server is a bit rough around the edges though, some sort of http framework 
>> is recommended. Here's my pick:
>>
>>  - Use connect (on which express is based) for the basic functionality ( 
>> http://www.senchalabs.org/connect/ ) as the webserver framework.
>>
>>  - Use bodyparser middleware for POST request bodies.
>>
>>  - Write your own middleware for API access.
>>
>>  - Use static middleware for static file serving from a directory
>>
>>  - You can copy&paste this gist: https://gist.github.com/klovadis/4988305
>>
>> Connect basically allows you to execute so called middleware functions on 
>> a http request in a linear order. Whenever a request comes in, each 
>> function does something (i.e. modify the request object to add cookie 
>> information) if applicable and continues to the next middleware, or 
>> responds to the request and skips the remaining middleware functions. So 
>> the order in which the middleware functions are added matters - you want to 
>> have decorating functions at the beginning and a "catch all" function at 
>> the end. The documentation of the exact workings of connect - to state 
>> things nicely - has room for improvement though.
>>
>> Express is based on connect and the way it works with middleware 
>> functions, but adds a lot of functionality for which you otherwise need to 
>> write your own middleware (i.e. a router or rendering jade templates out of 
>> the box). That is why lots of people do use express (*and tend to 
>> recommend it as the one and only solution whenever the word "webserver" is 
>> present*).
>>
>> In fact many other webserver frameworks do exist and are worth having a 
>> look at, but since I do know connect quite well by now I therefore 
>> recommend using it (without express on top of it).
>>
>> So in a nutshell: Place all your static files in a subfolder and let the 
>> "static" middleware serve them. Add api logic in a middleware function. No 
>> additional functionality is present. But do read up on the coolness of jade 
>> and stylus some time, there is a reason why people use those.
>>
>> All the best,
>>
>> Geerten
>>
>>
>> On Tuesday, February 19, 2013 3:35:53 PM UTC+1, kanitkar...@gmail.comwrote:
>>>
>>> Hi,
>>>
>>> I would like to do the following,
>>>
>>> 1) Have regular .html .css & .js files just like a normal web app
>>>
>>> 2) Interact with Node Js only through Ajax calls
>>>
>>> 3) But All files mentioned in 1) are also hosted on the same Node Http 
>>> server.
>>>
>>> So when I say http://localhost:3000/index.html, Node Js server should 
>>> give me index.html along with all css & js files included in it.
>>>
>>> Then my Javascript & Ajax code should drive the functionality with Node 
>>> program getting called by ajax request.
>>>
>>> Can anyone please please suggest me the best way to do this ?
>>>
>>> I don't want to use Jade or Stylus. I want to develop as if I am using 
>>> tomcat or wamp server & use power of Node where ever needed only.
>>>
>>> I am aware of express js framework but don't know how it will be useful 
>>> for above scenario.
>>>
>>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to