Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Jade Templates (jade-lang.com) client-side

Tags:

I'd like to use Jade templates client-side. Preferably generated using the Rails 3.1 asset pipeline. I can't really figure out how to do this.

Anyone who've stumbled upon the same problem and found a great solution? Any thoughts are much appreciated.

  • http://jade-lang.com/
  • http://ryanbigg.com/guides/asset_pipeline.html
like image 565
sandstrom Avatar asked Jul 04 '11 20:07

sandstrom


People also ask

Is Jade client side or server-side?

Jade is designed primarily for server-side templating in node.

How do I run a jade file?

All jade files need to be transformed in the HTML. Also don't forget that you need to install other dependencie like express, nodemailer, etc (see requires in the source code). And the application should by available on http://localhost/3000. All Jade templates will be correctly rendered and displayed as HTML.

Is Jade better than EJS?

EJS is way faster than Jade and handlebars. EJS has a really smart error handling mechanism built right into it. It points out to you, the line numbers on which an error has occurred so that you don't end up looking through the whole template file wasting your time in searching for bugs. Simple template tags: <% %>.


1 Answers

If you use browserify you can use this handy jade middleware: jadeify. Then you can just call jadeify("foo.jade", { x : 4, y : 5 }) browser-side after pointing a views directory at the middleware and you get back a jquery handle.

like image 81
substack Avatar answered Dec 25 '22 01:12

substack