HTML in Express and node.js? -


i don't know if noob question, have seen lot of documentation use express in node.js , express. see use lenguage called "jade" rendering html file. why? i'd know if necesary use jade or can render templates in express html.

no, it's not necessary use jade express. it's popular option since jade default generated applications , maintained same developer express.

they tend stay up-to-date each other, such addition of template inheritance in jade express dropped support layouts.

but, there number of other view engines offer built-in support express. and, consolidate project can mediator/glue have even more options:

  • atpl
  • dust
  • eco
  • ect
  • ejs
  • haml
  • haml-coffee
  • handlebars
  • hogan
  • jade
  • jazz
  • jqtpl
  • just
  • liquor
  • mustache
  • qejs
  • swig
  • templayed
  • toffee
  • underscore
  • walrus
  • whiskers

note: believe misunderstood question , answered broadly @ first. but, leaving rest of wrote below in case it's still useful.

it's not necessary use view engine express, can helpful.

express can .send() value response:

res.send(new buffer('whoop')); res.send({ some: 'json' }); res.send('some html'); 

but, view engine jade can generating more complex, data-driven content view/template. can keep project organized intent (separation of concerns), since views typically kept in own files.

albeit, view engine necessary if want use res.render(). method depends on 'view engine' application setting or you've configured app.engine().

app.set('view engine', 'jade'); // or ejs, swig, etc.  # ...  res.render('a-view'); // looks `a-view.jade` based on `'view engine'` 
app.engine('jade', require('consolidate').jade);  # ...  res.render('a-view.jade'); // matches extension `.engine()` 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -