I have a view in which the MIME type returned varies. How do I set the content type in the head section?
Here is what I am trying to do
!!!
html
head
title #{site.title} - #{site.version}
link(rel='stylesheet', href='/stylesheets/style.css')
script(type='text/javascript', src='/javascripts/jquery-1.5.1.min.js')
content-type #{mimetype}
body!= body
Now, write the following code to render above Jade template using Express. js. var express = require('express'); var app = express(); //set view engine app. set("view engine","jade") app.
All jade files need to be transformed in the HTML. Also don't forget that you need to install other dependencie like express, nodemailer, etc (see requires in the source code). And the application should by available on http://localhost/3000. All Jade templates will be correctly rendered and displayed as HTML.
EJS is way faster than Jade and handlebars. EJS has a really smart error handling mechanism built right into it. It points out to you, the line numbers on which an error has occurred so that you don't end up looking through the whole template file wasting your time in searching for bugs. Simple template tags: <% %>.
Jade is a template engine for node. js and the default rendering engine for the Express web framework. It is a new, simplified language that compiles into HTML and is extremely useful for web developers. Jade is designed primarily for server-side templating in node.
You can specify the content-type meta tag like so:
meta(http-equiv="content-type", content="#{contentType}; charset=UTF-8")
Remember that the tag for content-type is <META ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With