A Twitch.tv viewer reward and games system.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
5.3 KiB

  1. # [![Jade - template engine ](http://i.imgur.com/5zf2aVt.png)](http://jade-lang.com/)
  2. Full documentation is at [jade-lang.com](http://jade-lang.com/)
  3. Jade is a high performance template engine heavily influenced by [Haml](http://haml-lang.com)
  4. and implemented with JavaScript for [node](http://nodejs.org). For discussion join the [Google Group](http://groups.google.com/group/jadejs).
  5. You can test drive Jade online [here](http://naltatis.github.com/jade-syntax-docs).
  6. [![Build Status](https://travis-ci.org/visionmedia/jade.png?branch=master)](https://travis-ci.org/visionmedia/jade)
  7. [![Dependency Status](https://gemnasium.com/visionmedia/jade.png)](https://gemnasium.com/visionmedia/jade)
  8. [![NPM version](https://badge.fury.io/js/jade.png)](http://badge.fury.io/js/jade)
  9. ## Announcements
  10. **Deprecation of implicit script/style text-only:**
  11. Jade version 0.31.0 deprecated implicit text only support for scripts and styles. To fix this all you need to do is add a `.` character after the script or style tag.
  12. It is hoped that this change will make Jade easier for newcomers to learn without affecting the power of the language or leading to excessive verboseness.
  13. If you have a lot of Jade files that need fixing you can use [fix-jade](https://github.com/ForbesLindesay/fix-jade) to attempt to automate the process.
  14. **Command line option change:**
  15. since `v0.31.0`, `-o` is preferred for `--out` where we used `-O` before.
  16. ## Installation
  17. via npm:
  18. ```bash
  19. $ npm install jade
  20. ```
  21. ## Syntax
  22. Jade is a clean, whitespace sensitive syntax for writing html. Here is a simple example:
  23. ```jade
  24. doctype html
  25. html(lang="en")
  26. head
  27. title= pageTitle
  28. script(type='text/javascript').
  29. if (foo) bar(1 + 5)
  30. body
  31. h1 Jade - node template engine
  32. #container.col
  33. if youAreUsingJade
  34. p You are amazing
  35. else
  36. p Get on it!
  37. p.
  38. Jade is a terse and simple templating language with a
  39. strong focus on performance and powerful features.
  40. ```
  41. becomes
  42. ```html
  43. <!DOCTYPE html>
  44. <html lang="en">
  45. <head>
  46. <title>Jade</title>
  47. <script type="text/javascript">
  48. if (foo) bar(1 + 5)
  49. </script>
  50. </head>
  51. <body>
  52. <h1>Jade - node template engine</h1>
  53. <div id="container" class="col">
  54. <p>You are amazing</p>
  55. <p>Jade is a terse and simple templating language with a strong focus on performance and powerful features.</p>
  56. </div>
  57. </body>
  58. </html>
  59. ```
  60. The official [jade tutorial](http://jade-lang.com/tutorial/) is a great place to start. While that (and the syntax documentation) is being finished, you can view some of the old documentation [here](https://github.com/visionmedia/jade/blob/master/jade.md) and [here](https://github.com/visionmedia/jade/blob/master/jade-language.md)
  61. ## API
  62. For full API, see [jade-lang.com/api](http://jade-lang.com/api/)
  63. ```js
  64. var jade = require('jade');
  65. // compile
  66. var fn = jade.compile('string of jade', options);
  67. var html = fn(locals);
  68. // render
  69. var html = jade.render('string of jade', merge(options, locals));
  70. // renderFile
  71. var html = jade.renderFile('filename.jade', merge(options, locals));
  72. ```
  73. ### Options
  74. - `filename` Used in exceptions, and required when using includes
  75. - `compileDebug` When `false` no debug instrumentation is compiled
  76. - `pretty` Add pretty-indentation whitespace to output _(false by default)_
  77. ## Browser Support
  78. The latest version of jade can be download for the browser in standalone form from [here](https://github.com/visionmedia/jade/raw/master/jade.js). It only supports the very latest browsers though, and is a large file. It is recommended that you pre-compile your jade templates to JavaScript and then just use the [runtime.js](https://github.com/visionmedia/jade/raw/master/runtime.js) library on the client.
  79. To compile a template for use on the client using the command line, do:
  80. ```console
  81. $ jade --client --no-debug filename.jade
  82. ```
  83. which will produce `filename.js` containing the compiled template.
  84. ## Command Line
  85. After installing the latest version of [node](http://nodejs.org/), install with:
  86. ```console
  87. $ npm install jade -g
  88. ```
  89. and run with
  90. ```console
  91. $ jade --help
  92. ```
  93. ## Additional Resources
  94. Tutorials:
  95. - cssdeck interactive [Jade syntax tutorial](http://cssdeck.com/labs/learning-the-jade-templating-engine-syntax)
  96. - cssdeck interactive [Jade logic tutorial](http://cssdeck.com/labs/jade-templating-tutorial-codecast-part-2)
  97. - in [Japanese](http://blog.craftgear.net/4f501e97c1347ec934000001/title/10%E5%88%86%E3%81%A7%E3%82%8F%E3%81%8B%E3%82%8Bjade%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%B3)
  98. Implementations in other languages:
  99. - [php](http://github.com/everzet/jade.php)
  100. - [scala](http://scalate.fusesource.org/versions/snapshot/documentation/scaml-reference.html)
  101. - [ruby](https://github.com/slim-template/slim)
  102. - [python](https://github.com/SyrusAkbary/pyjade)
  103. - [java](https://github.com/neuland/jade4j)
  104. Other:
  105. - [Emacs Mode](https://github.com/brianc/jade-mode)
  106. - [Vim Syntax](https://github.com/digitaltoad/vim-jade)
  107. - [TextMate Bundle](http://github.com/miksago/jade-tmbundle)
  108. - [Coda/SubEtha syntax Mode](https://github.com/aaronmccall/jade.mode)
  109. - [Screencasts](http://tjholowaychuk.com/post/1004255394/jade-screencast-template-engine-for-nodejs)
  110. - [html2jade](https://github.com/donpark/html2jade) converter
  111. ## License
  112. MIT