/scalate-website/src/documentation/jade.page

http://github.com/scalate/scalate · Visualforce Page · 115 lines · 93 code · 22 blank · 0 comment · 0 complexity · cc5403f7944de2e92edee1b2c734b567 MD5 · raw file

  1. ---
  2. title: Jade Reference
  3. --- name:overview
  4. # Jade Reference Guide
  5. Jade is the daddy of HTML template engines for Scala
  6. --- name:content pipeline:markdown
  7. [Jade](http://jade-lang.com/) is a [neater](jade-syntax.html) dialect of [Haml](http://haml-lang.com/) / [Scaml](scaml-reference.html) which is a very DRY template language for creating HTML markup.
  8. Here's a simple Jade example
  9. {pygmentize_and_compare::}
  10. -----------------------------
  11. jade: An example .jade file
  12. -----------------------------
  13. !!! 5
  14. html(lang="en")
  15. head
  16. title= pageTitle
  17. :javascript
  18. if (foo) {
  19. bar()
  20. }
  21. body
  22. h1 Jade - node template engine
  23. #container
  24. - if (youAreUsingJade)
  25. p You are amazing
  26. - else
  27. p Get on it!
  28. :coffeescript
  29. alert "Hello, Coffee!"
  30. -----------------------------
  31. xml: the generated HTML
  32. -----------------------------
  33. <!DOCTYPE html>
  34. <html lang="en">
  35. <head>
  36. <title>Jade</title>
  37. <script type="text/javascript">
  38. //<![CDATA[
  39. if (foo) {
  40. bar()
  41. }
  42. //]]>
  43. </script>
  44. </head>
  45. <body>
  46. <h1>Jade - node template engine</h1>
  47. <div id="container">
  48. <p>You are amazing</p>
  49. </div>
  50. <script type='text/javascript'>
  51. //<![CDATA[
  52. (function() {
  53. alert("Hello, Coffee!");
  54. }).call(this);
  55. //]]>
  56. </script>
  57. </body>
  58. </html>
  59. {pygmentize_and_compare}
  60. If you already know [Haml](http://haml-lang.com/) / [Scaml](scaml-reference.html) then Jade which basically avoids the use of % before element names making things a little easier to read; then for text content on a new line you either prefix the text with the **|** symbol or you use a markup format like markdown.
  61. If you don't know [Haml](http://haml-lang.com/) / [Scaml](scaml-reference.html), please refer to the [Jade Syntax](jade-syntax.html).
  62. ## Markdown and Jade rock
  63. Jade and markdown are the perfect couple for your HTML templating needs; Jade provides the very DRY and concise HTML markup using concise CSS aware markup, markdown provides the wiki formatting of text blocks.
  64. Jade by itself is great for structural markup and layouts but is not always optimal for lots of text with embedded markup like bold and hyperlinks.
  65. Here's an example of some text markup with hyperlinks using vanilla jade
  66. {pygmentize:: jade}
  67. .foo
  68. p
  69. | This is some
  70. b text
  71. | with a
  72. a(href="http://fusesource.com") FuseSource
  73. | link.
  74. {pygmentize}
  75. Now lets use [markdown](http://daringfireball.net/projects/markdown/) - which is great for concise DRY text with markup effects and embedded links..
  76. {pygmentize:: jade}
  77. .foo
  78. :markdown
  79. This is some **text** with a [FuseSource](http://fusesource.com) link.
  80. {pygmentize}
  81. Both of which should generate something like this
  82. {pygmentize:: xml}
  83. <div class="foo">
  84. <p>
  85. This is some <b>text</b> with a <a href="http://fusesource.com">FuseSource</a> link.
  86. </p>
  87. </div>
  88. {pygmentize}
  89. ## See Also
  90. * [Jade Syntax](jade-syntax.html)
  91. * [Markdown Syntax](http://daringfireball.net/projects/markdown/syntax)
  92. * [User Guide](user-guide.html)
  93. * [Documentation](index.html)