I decided to play a bit with Node.js because I like Javascript a lot as a language and because V8 is so fast. I work with mobile sites a so if I manage to reduce the page response time it will be very good.
I have a relatively simple site built with php and smarty and as an exercise I want to port it to Node and see how it behaves.
My main problem is the following - which of the existing template engines most closely resemble smarty so the porting work of this part of the project to be minimized.
Also I use php library that combines content images into sprites - any image processing tools for V8 that can read/write png and jpeg?
Recently published Node.js Smarty template engine - ported PHP Smarty
https://github.com/stepofweb/nsmarty
When I search for modules I like to use http://search.npmjs.org and https://github.com/joyent/node/wiki/modules.
I have never used Smarty, but maybe ejs could be useful? There is a node.js plugin for ejs available. Also maybe you should have a look at all templates modules available at https://github.com/joyent/node/wiki/modules#wiki-templating.
I searched search.npmjs.org and https://github.com/joyent/node/wiki/modules for png:
https://github.com/pkrumins/node-png
https://github.com/pkrumins/node-image
Related
I'm writing some example code using node and express, that is targeted at beginner to intermediate front end developers (not node.js or express developers). Basically some plug and play code that allows a beginner dev to get right to the HTML, CSS and behavioral JavaScript, and host it on a simple hosting solution like Heroku.
I need a recommendation for a an express compatible templating language that is very light and simple to understand.
I need:
Variables embedded in the template.
Loops and if statements embedded in the template.
I want to avoid:
Unusual syntax (Jade).
Files that are not named .html (like
mustache).
Unusual looking configuration (for example to force mustache to use .html as an extension).
I need something really basic. Should I role my own, or is there a lightweight, well support third party solution I should be aware of?
I would check out EJS. It is pretty decent and fairly easy to use. It is also compatible with Angular. I go back and forth using EJS and Dust.
EJS is very forgiving and easy to get started.
I’d like to move away from Wordpress with my blog which may also contain pages with different layouts/design. Therefore I’m looking for suggestions for a full web-stack which meets my requirements below.
I would like to use Node.js and also DocPad for the blog itself but DocPad seems not to be made for the kind of dynamic content I’d like to have.
These are most of my requirements:
dynamic content (like unlimited scrolling for posts, switching categories without fully reloading a page) crawlable by
search-engines crawlable by search-engines
multi-lingual blogging with markdown
atom-feeds
sitemap-generation
full-text search for articles / pages
manage/count downloads
pages may have a different designs/template (e.g. if I want to experiment with HTML5 or anything)
embed media from YouTube, Soundcloud etc.
responsive layout
Technologies which are set
Node.js
Express
I’m eyeing with the following technologies as well (this is not a stack, just technologies I find interesting):
Ember.js for the client-side
Foundation
DocPad
Mongo DB
Grunt
I will recommend you Mean.js It's a complete stack of nodejs, express using mongodb. Frontend is based on angular I think is very powerful and you can use yeoman generator to avoid to write a lot of boilplate code.
I heard that mean.io is very useful too but I didn't use it yet.
Take a look here http://meanjs.org/
EDIT: Here is an interesting thread about this two stacks Difference between MEAN.js and MEAN.io
This may come from a lack of experience on the various sections of the MEAN stack, but from the various boilerplates I've seen (mean.io, hackathon-starter, etc.) in the app.js code, there is always a call to using jade templating engine. I know that I can switch this to ejs and the like, but I was wondering if there's a means of doing it to where all of my pages are .html files using AngularJS? The components/templating features I'm interested appear to be in Angular already so I'm not sure what I'm losing if I were to attempt to server .html files instead?
If you have multiple html pages in your application, template engine can reduce code duplication between them.
Also, you usually need server-side template engine to provide some kind of a fallback to users who don't have javascript turned on (+ search engines).
I prefer jade over other template engines (and plain html), precisely because it's not html. So it doesn't have certain html issues like whitespace nodes, and always compiles into well-formed html file.
If you follow meanjs.org it uses swig, which parses as HTML. You may consider doing the same?
Is there a module or similar things that support skinning in NodeJS? I want to build a NodeJS website, and want to be able to re-skin the website as I like without much efforts, like in Wordpress.
Is skinning supported in NodeJS?
If you're interested in building a website in Node.js and don't need a wordpress-style cms behind it, there are few projects that can help you out.
Have you looked into Bootstrap? It's built with less which you can easily plug in to your Express setup (see the guide here, using the command line executable to set up a new project you can specify less like this: express --css less myapp and it will do all the work for you)
In the bootstrap less file are several variables you can use to change the colours, fonts, sizes, etc, and it's also got a lot of helpers for grid layouts and responsive designs.
It even includes a few useful javascript plugins too which make the ui nicer with less work.
There are also a lot of sites with themes and theme generators around which then work on top of bootstrap, and may achieve what you want.
Plugging in this sort of solution (whether bootstrap or other) is about as close as you can come to getting skinning for node; As otherwise suggested if you're looking for a CMS out of the box as well, probably best to look for another platform like Wordpress.
Node.js is not a content management system. It is a platform on top of which you could built a web server with a content management system. To answer your question you need to be looking for node.js based content management systems that support themes.
The only node.js CMS that I am aware of is Calipso. It's still pretty alpha-stage. It may have some theming support, but it is nowhere near as polished as Wordpress.
Also is there a reason why you want to use node.js? I mean there is nothing wrong in using Wordpress for creating a themeable website - it is just awesome for that.
If you just want another OnlineShop, or maybe a blog, i think nodejs is maybe not your right choose as Jed Watson told.
If your requirements are more complicated, and you want a quick and easy implementation of a nice web interface, and you have html, javascript, and css knowledge... I strongly recommend you just trying to work with MEAN.js
It puts together MongoDB Expressjs, AngularJs, and NodeJs.
Use this, for example with a yeoman fullstack constructor and you will have a powerful webapp, with user autentication, and much more in a few minutes.
After that, the use of jade, less, scss, and similar languages of modelling the front, and the easy way you can also model collections in the back, is for me the best combination you´ll find for creating a website today.
Hope it´ll help you
King Regards
I am looking to reuse templates I write for NodeJS in the browser, by this I hope to gain fast page loading time (initial rendering), and dynamic content switching ability, etc...
This would be most natural on Node, any ideas of compatible templating engines?
By the way, I like the HAML style syntax, so anything HAML based is a huge plus.
Thanks!
Roman
Edit:
I think that I like the approach of Mustache the most, it works with Express and also in client side.. will update here on how the implementation went..
Jade is excellent, very similar to HAML and compiles down to JavaScript for browser usage :)
See the README on the Github repo for details.
Jade is also the semi-officially recommended template language for the currently most popular web framework for Node, Express (in fact, they share authors), so it looks like a solid choice to me.
I recently evaluated a lot of NodeJS template libraries and ended up picking Jade.
I've made a simple example of using Jade in the browser. The fun stuff happens in demo.js, and you can also view index.jade which contains the basic page markup.
EJS works in the browser and with express out of the box. Admittedly the syntax is not HANL style nor is particularly feature rich but you can easily get it to work.
I've also used a simple technique to re-use templates and views on both client and server and it works reasonably well
JAVASCRIPT TEMPLATE SHOWDOWN!~
Which is pretty much all the best templates lined up to test in the browser.
(also #Raynos it includes an example of jade in the browser)
Personally I use Jade, combined with stylus and jquery I only use css selectors.
But. . . as you can see from the chart Jade doesn't get along with firefox 3 or opera.
You could try weld https://github.com/hij1nx/weld that has implementation in server side and client side.
node-jqtpl is your best bet. It's a port of jQuery Templates, so 100% reusable in the browser.
There is a command-like utility TplCpl written in Node.js that allows to compile Jade templates for browser use.
https://github.com/jsmarkus/tplcpl