Is there a jade template engine for ASP.NET MVC?
Asked Answered
T

3

20

I've always been searching for a best suitable ViewEngine for me in ASP.NET MVC, and after observing a ton of template engines in either JAVA, PHP, Python, Ruby, NodeJS... I found the jade template and loved it since it has some really nice features:

  1. Encode all html by default, just like razor, it's a nice addition to security and convinence
  2. Structure by indent, so get rid of the tag hell, after writing HTML for years, I hate all those < and >!
  3. Clear logic code, by preceding if/else/for by a single line "-" it minimize the code for choice and loop.
  4. Whitespace strip, jade outputs "compressed" html which do not have extra whitespace between tags or texts

I have also observed many ViewEnginge for ASP.NET MVC, some are quite close to jade, but still with defects:

  • NHaml structures the HTML by indent, but donot encode html by default, and the tag prefix % are really annoying
  • Razor may be the only ViewEngine which encodes html by default, but it's still a little heavy for me since razor's basic markup is still html tags, and also razor could not strip extra whitespace for me

so I wounder if there is a ViewEngine closer to jade, ot is there an port of jade to .NET?

Thanks

Tenotomy answered 7/9, 2011 at 7:53 Comment(0)
P
0

It's not as clean as Jade, but you won't have to write 'real' HTML, with WingBeats.

Perretta answered 7/9, 2011 at 8:35 Comment(3)
Thanks, it seems acceptable to have a new DSL, it's quite clean so I would have a try :)Tenotomy
Maybe it's just me but that is hideous syntax.Subject
@AlexFord it's not just you. it's hideous.Emphysema
T
25

The Spark View Engine supports parsing Jade templates as of v1.7 (4/12).

Read More: http://sparkviewengine.codeplex.com/releases/view/86901

Install via NuGet package:

Install-Package Spark.Web.Mvc3

or

Install-Package Spark.Web.Mvc2

Read More: http://nuget.org/packages/Spark.Web.Mvc3

Theomania answered 13/5, 2012 at 5:24 Comment(3)
How do you make spark recognize *.shade files? with the latest version it still looks for spark not shadeLole
Why is this not a bigger deal!? This is awesome!Subject
While it's a good start, it's support is minimal and has some syntax incompatibilities with original Jade. In particular it doesn't seem to support doctypes or attributes.Papen
P
0

It's not as clean as Jade, but you won't have to write 'real' HTML, with WingBeats.

Perretta answered 7/9, 2011 at 8:35 Comment(3)
Thanks, it seems acceptable to have a new DSL, it's quite clean so I would have a try :)Tenotomy
Maybe it's just me but that is hideous syntax.Subject
@AlexFord it's not just you. it's hideous.Emphysema
D
0

This is a really fresh project so results may vary depending on the time you read this: https://github.com/Buildstarted/Javascript.ViewEngines

This is the article introducing it: http://buildstarted.com/2013/12/16/javascript-view-engine-for-aspnet/

Supports Haml, Dust, Handlebars, Jade, Mustache, Resig, Underscore, Vash

Deplete answered 16/12, 2013 at 14:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.