Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember.js on the server

I'm developing a very dynamic web application via ember.js. The client-side communicates with a server-side JSON API. A user can make various choices and see diced & filtered data from all kinds of perspectives, where all of this data is brought from said API.

Thing is, I also need to generate static pages (that Google can understand) from the same data. These static pages represent pre-defined views and don't allow much interaction; they are meant to serve as landing pages for users arriving from search engines.

Naturally, I'd like to reuse as much as I can from my dynamic web application to generate these static pages, so the natural direction I thought of going for is implementing a server-side module to render these pages which would reuse as much as possible of my Ember.js views & code.

However - I can't find any material on that. Ember's docs say "Although it is possible to use Ember.js on the server side, that is beyond the scope of this guide."

Can anyone point out what would be possible to reuse on the server-end, and best practices for designing the app in a way to enable maximal such reuse?

Of course, if you think my thinking here doesn't make sense, I'd be glad to hear this (and why) too :-)

Thanks! C.

like image 899
Chasseur Avatar asked Jun 22 '12 20:06

Chasseur


People also ask

Do people still use Ember JS?

Yes, less people use it -- that's just the truth. Every year, during the "State of the Web" survey or the NPM survey, Ember will come in behind React, Vue and Angular.

Is Ember a server side framework?

Ember JS is a client-side JavaScript framework for creating aspiring single-page web apps. It is an open-source JavaScript web framework that enables developers to build scalable single-page web applications by integrating other single-page app ecosystem principles.

Is Ember JS frontend or backend?

Ember. js is one component of a complete front end stack built and supported by the Ember core team.


1 Answers

Handlebars - Ember's templating engine - does run on the server (at least under Node.js). I've used it in my own projects.

When serving an HTTP request for a page, you could quite possibly use your existing templates: pull the relevant data from the DB, massage it into a JSON object, feed it to handlebars along with the right template, then send the result to the client.

like image 66
afters Avatar answered Sep 28 '22 13:09

afters