Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 653
otakustay Avatar asked Sep 07 '11 07:09

otakustay


People also ask

What is Jade template engine?

Jade is a template engine for node. js and the default rendering engine for the Express web framework. It is a new, simplified language that compiles into HTML and is extremely useful for web developers. Jade is designed primarily for server-side templating in node.

Is Jade template engines can be used with node js?

Jade is a template engine for Node. js. Jade syntax is easy to learn. It uses whitespace and indentation as a part of the syntax.

What is Jade file extension?

Jade is a markup language that removes the ceremony with creating XML based files (such as . html or . xml files).

What is Jade and pug?

js, also known as PUG, is a Javascript library that was previously known as JADE. It is an easy-to-code template engine used to code HTML in a more readable fashion. One upside to PUG is that it equips developers to code reusable HTML documents by pulling data dynamically from the API.


1 Answers

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

like image 180
Chris Vogt Avatar answered Oct 03 '22 23:10

Chris Vogt