MEAN stack - reliance on templating (Angular vs Templating Engines)?
Asked Answered
R

2

8

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?

Romberg answered 22/2, 2014 at 18:52 Comment(5)
I'm using MEAN stack as well and don't use Jade or EJS at all. I can live with plain HTML, especially for Single Page Web Applications (SPWA). BTW all static files are delivered by nginx, not node.js.Crine
Is there a benefit to a templating engine? What would be gained? Do you lose any type of functionality?Romberg
AngularJS does templating on client-side and has 2-way data binding. Most examples of EJS and the like seem to me like 1999 Active Server Pages or plain JSP. Use Express as a REST backend, send and receive JSON and use AngularJS on client. I wouldn't combine client-side templating and server-side at all (at least not too much). This is true for web applications without need for SEO. If you have web pages and need SEO, take Jade/EJS and use AngularJS only for small spots.Crine
Odd. Won't let me edit. Do you lose any type of functionality by foregoing the use of templating engines, I mean. Edit: that sounds like a pretty good answer.Romberg
The problem: this is not an answer, but an opinion. You'll find guys who think totally different. It highly depends on what you want to do. If you want, edit your question, describe what kind of application you want to develop and we can discuss pros/cons of the different templating options. There's no golden hammer...Crine
B
3

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.

Breathe answered 23/2, 2014 at 13:20 Comment(0)
H
3

If you follow meanjs.org it uses swig, which parses as HTML. You may consider doing the same?

Hoedown answered 6/4, 2014 at 8:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.