Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer EJS over Jade? #26

Closed
michael opened this issue Feb 3, 2013 · 11 comments
Closed

Prefer EJS over Jade? #26

michael opened this issue Feb 3, 2013 · 11 comments
Milestone

Comments

@michael
Copy link
Owner

michael commented Feb 3, 2013

I find myself disliking the Jade template language... ;) so I wonder if we shouldn't switch to EJS instead.

  • we can mix with existing html (i don't like the step of converting html to prooper jade code)
  • we use the same templating as on the client-side (Composer)
  • I like being able to write javascript code right in the templates. Sure we need to take care we don't put logic into our templates but that's more of a matter of applying good practices, I think it doesn't justify for introducing a new language.

What's your opinion on that, @yuchi ?

@yuchi
Copy link
Collaborator

yuchi commented Feb 3, 2013

I usually love Jade terse syntax, and most of all I love it's mixin abilities. EJS does not offer a taglib like feature. I love Java's JSPs' taglib, they are able to convey common snippets in a html/xml like syntax:

<!-- insead of -->
<div class="user-avatar"><img src="<%= GravatarUtil.toURL(user.getEmail(), 128) %>"></div>
<!-- you can use -->
<hub:avatar user="<%= user %>" size="128" />

In jade you can do it similarly (see the docs for an example).

Jade, also, force you to remove logics in the views. Every logic will get your views "dirty", and I usually see this as a feature.

About embedded js, you can always do the following:

- var rand = function () {
-   return Math.random() > 0.5 ? "selected" : "normal";
- };
menu
  ul
    li.menu-item(class=rand()) Notice how classes are merged

At the same time I do understand you concerns about Jade, I was thinking about the switch too. But I'll miss the extension structure...

@Integral
Copy link
Collaborator

Integral commented Feb 3, 2013

Do you guys going to use express? 3.x version have changes related to
template engines.

On 3 February 2013 23:41, Pier Paolo Ramon notifications@github.com wrote:

I usually love Jade terse syntax, and most of all I love it's mixin
abilities. EJS does not offer a taglib like feature. I love Java's JSPs'
taglib, they are able to convey common snippets in a html/xml like syntax:

In jade you can do it similarly (see the docshttps://github.com/visionmedia/jade#a14for an example).

Jade, also, force you to remove logics in the views. Every logic will get
your views "dirty", and I usually see this as a feature.

About embedded js, you can always do the following:

  • var rand = function () {- return Math.random() > 0.5 ? "selected" : "normal";- };menu
    ul
    li.menu-item(class=rand()) Notice how classes are merged

At the same time I do understand you concerns about Jade, I was thinking
about the switch too. But I'll miss the extension structure...


Reply to this email directly or view it on GitHubhttps://github.com//issues/26#issuecomment-13052446.

@yuchi
Copy link
Collaborator

yuchi commented Feb 3, 2013

We''re already on Express 3 ;)

@Integral
Copy link
Collaborator

Integral commented Feb 3, 2013

Oh, good.
Btw, I'll gladly join to you next week ;)

On 3 February 2013 23:48, Pier Paolo Ramon notifications@github.com wrote:

We''re already on Express 3 ;)


Reply to this email directly or view it on GitHubhttps://github.com//issues/26#issuecomment-13052590.

@yuchi
Copy link
Collaborator

yuchi commented Feb 3, 2013

Mh... From (rails based) Hobo's DRYML (which in my opinion should be written DryML) there's a node port which implements EJS like syntax which support taglibs in a similar manner... but looks terrible, and DryML itself it's like taking the good parts of JSP and the bad parts. It's like taking 10 years old errors into fresh new frameworks. Cool! </irony>

@yuchi
Copy link
Collaborator

yuchi commented Feb 3, 2013

Oh, @Integral, welcome aboard!

@michael
Copy link
Owner Author

michael commented Feb 3, 2013

@yuchi Yeah I went through all stages of template languages as well. Erb, HAML, SASS, Mustache et al. However for me I figured out even if I break the rules sometimes intentionally, views can be kept dry by just using a dumb templateing mechanism and have less complexity. And then while you're in the middle of implementing an exciting feature, there's nothing wrong with calling Date.toDateString() and the likes from within the template (that's not logic for me) :)

Well if we consider a switch I'd just use underscore's _.template method and accept we don't have taglibs. Otherwise we can stick with Jade. Just wanted to bring up that discussion before we have more template code to maintain.

@michael
Copy link
Owner Author

michael commented Feb 3, 2013

@Integral welcome! :)

@yuchi
Copy link
Collaborator

yuchi commented Feb 3, 2013

Mh, ok. Let's make it. We'll have stronger consistencies between the parts of the Substance stack.

But... we should try it a little before going "full dumb" (quote), I'm scared of spaghetti templates. In fact jade forced me to stay clean.

@michael
Copy link
Owner Author

michael commented Feb 7, 2013

@yuchi Do you think we should just tackle this? If we'd like to switch to EJS we should do it earlier than later I guess. I'll put my focus more on the composer side for the coming weeks, so maybe you or @vectorsize would like to look into this?

@yuchi
Copy link
Collaborator

yuchi commented Feb 7, 2013

Ok, I close this issue. I'm creating the real one.

@yuchi yuchi closed this as completed Feb 7, 2013
@yuchi yuchi mentioned this issue Feb 7, 2013
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants