Re: Layout.ejs not working in Express

2,503 views
Skip to first unread message

tjholowaychuk

unread,
Aug 11, 2012, 11:17:17 AM8/11/12
to Express
naturally like all software things change... tutorials don't stay
relevant forever. Express no longer
takes care of the layout / partial concepts, engines can do this
themselves.

https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x

On Aug 10, 10:47 am, karl unger <unger.kar...@gmail.com> wrote:
> I'm new to node.js. So I decided to read and try out some of the tutorial.
> I installed node.js, npm installed packages as described on the tutorial
> websites. Everything worked fine until I installed express and ejs. None of
> the tutorials worked out. Layout.ejs was never used. After much frustration
> and many days of trying to figure out what was going on I find out that
> express 3.0 does not (yet) support layouts in ejs. Seehttp://stackoverflow.com/questions/11751114/layout-ejs-doesnt-work-on...
>
> I uninstalled express 3.0 and installed the earlier 2.5 version and
> everything works fine.
>
> My question is why would npm install express, install an incomplete version
> of express? Why not install a stable version as a default and allow user to
> install a version in development if they choose? Why isn't there any
> mention of this (and possibly other things yet not working in express 3.0)
> on the express.com website?
>
> It's extremely frustrating particularly to someone new to node.js to find
> out that basic information is not available or not posted.

anupka...@gmail.com

unread,
Aug 11, 2012, 11:22:24 AM8/11/12
to expre...@googlegroups.com
I think removing out the layout thing was really good. It does not force you to work with what's good for others. For example I have been using ejs and its really cool. Some ppl on the list here use jade. Its really cool. Even I was totally frustrated with this but not any more.
Sent on my BlackBerry® from Vodafone
--
You received this message because you are subscribed to the Google Groups "Express" group.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.

Felix Weiss

unread,
Sep 2, 2012, 7:19:52 AM9/2/12
to expre...@googlegroups.com
Keith, thanks for your wise words! I absolutely agree with you and also don't understand this decision why layouts were removed from Express 3. A good developer always follows the DRY concept and this is not possible with other template engines anymore. I was so happy, now you can generate Express apps with Hogan.js via "$express <appname> --hogan", but layout partials still don't work, yet.

I like Express over other node web frameworks like Flatiron, but to be forced to use Jade with a nonstandard syntax, if you need to build DRY apps with layout partials... developers have to decide whether they accept Jade or not, because it doesn't make sense to use other template engines without layout partials.

Hopefully the maintainers by Express understand, that developers want to decide for themselves. At least generated apps with express --ejs or --hogan should support layout partials, because outside of Express they do and therefore it's expected.


 

Am Sonntag, 2. September 2012 05:40:16 UTC+2 schrieb Keith Rosenberg:
Very insightful post, saved me some grief. I'm just curious why this decision was made? In the migration doc says it "enables view engines to supply their own means of inheritance" - the only problem with this is that as they dont :-) Jade does, and that's cool, but (totally biased opinion) Jade is awful (I'll probably love it in 6 months). Looking at markdown like that, for me, is very unsightly, chaotic, and disorderly, and I don't trust Jade to render it properly or myself to write it in a way Jade will render it properly. As a user, I'm not looking for markdown, I am looking for the ability to tell my page to dynamically render a variable. I don't think it's fair that I should have to use Jade and learn the syntax of Jade just to tell my page to render the logged in user's name.

My point is, it's cool that Express wants to leave it to the other guy, but I don't think it should. It just seems like Express is tying itself to Jade and tying its users to Jade, unless they install some third party module which may or may not continue to be maintained and may or may not work with the next release of Express core. It's probably difficult to keep up with everything, but Jade is pretty far-fetched markdown. EJS is more of a templating language, where Jade is Markdown. Even moustache.js would be more acceptable. Or if Jade had the capacity to read markup (without having to use their syntax) and let you only use trigger Jade  when you wanted it for dynamic page data, maybe then it would be all right, but I read through the docs and it seems like you need to use some obscure pipe or . operators to achieve this. 

Felix Weiss

unread,
Sep 2, 2012, 7:52:48 AM9/2/12
to expre...@googlegroups.com
I just found this discussion and the guys are working on it: https://github.com/visionmedia/ejs/issues/35

:-)
Reply all
Reply to author
Forward
0 new messages