[Pkg-javascript-commits] [node-jade] 01/14: Imported Upstream version 1.7.0
Leo Iannacone
l3on-guest at moszumanska.debian.org
Fri Oct 17 11:16:29 UTC 2014
This is an automated email from the git hooks/post-receive script.
l3on-guest pushed a commit to branch master
in repository node-jade.
commit 4f74909e246408349e105c80ab836c13676ec44c
Author: Leo Iannacone <l3on at ubuntu.com>
Date: Fri Oct 10 16:58:32 2014 +0200
Imported Upstream version 1.7.0
---
.gitignore | 12 -
History.md | 19 +
bin/jade.js | 5 +
component.json | 4 +-
docs/versions.json | 4 +-
docs/views/api.jade | 3 +
docs/views/command-line.jade | 1 +
docs/views/reference.jade | 1 +
docs/views/reference/attributes.jade | 80 +-
docs/views/reference/code.jade | 44 +-
docs/views/reference/comments.jade | 2 +-
docs/views/reference/doctype.jade | 41 +-
docs/views/reference/extends.jade | 2 +-
docs/views/reference/inheritance.jade | 104 +++
docs/views/reference/iteration.jade | 20 +-
docs/views/reference/mixins.jade | 48 +-
docs/views/reference/tags.jade | 16 +
jade-language.md | 1023 ------------------------
jade.md | 510 ------------
lib/compiler.js | 33 +-
lib/filters-client.js | 3 +-
lib/filters.js | 5 +-
lib/jade.js | 17 +-
lib/lexer.js | 14 +-
lib/parser.js | 1 +
lib/self-closing.js | 22 -
lib/utils.js | 6 +
package.json | 11 +-
test/cases/auxiliary/mixin-at-end-of-file.jade | 3 +
test/cases/mixin-at-end-of-file.html | 3 +
test/cases/mixin-at-end-of-file.jade | 4 +
test/cases/mixin.attrs.html | 3 +-
test/cases/mixin.attrs.jade | 5 +
test/cases/mixins.html | 10 +
test/cases/mixins.jade | 2 +
test/cases/mixins.rest-args.html | 6 +
test/cases/mixins.rest-args.jade | 6 +
test/error.reporting.js | 8 +
test/fixtures/issue-1593/include-layout.jade | 2 +
test/fixtures/issue-1593/include.jade | 4 +
test/fixtures/issue-1593/index.jade | 7 +
test/fixtures/issue-1593/layout.jade | 3 +
test/jade.test.js | 8 +
43 files changed, 507 insertions(+), 1618 deletions(-)
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index a85fb8f..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,12 +0,0 @@
-.DS_Store
-.idea
-lib-cov
-testing
-node_modules
-lib-cov
-coverage
-npm-debug.log
-/test/output
-/test/temp
-/docs/out
-.release.json
diff --git a/History.md b/History.md
index b97a158..2f387ae 100644
--- a/History.md
+++ b/History.md
@@ -1,3 +1,22 @@
+1.7.0 / 2014-09-17
+==================
+
+ * Add Doctype option on command line ([@ForbesLindesay](http://www.forbeslindesay.co.uk/))
+ * Support ES6 style rest args in mixins ([@ForbesLindesay](http://www.forbeslindesay.co.uk/))
+ * Fix support for unicode newlines (\u2028, \u2029) ([@rlidwka](https://github.com/rlidwka))
+ * Expose `globals` option from the `with` module ([@sokra](https://github.com/sokra))
+ * Lots of new documentation ([@ForbesLindesay](http://www.forbeslindesay.co.uk/))
+
+1.6.0 / 2014-08-31
+==================
+
+ * Allow optional white space after `+` when calling a mixin ([@char101](https://github.com/char101))
+ * Use void-elements module to replace internal self-closing list ([@hemanth](https://github.com/hemanth))
+ * Fix a warning that eroniously warned for un-used blocks if in an extending template from an include (Reported by [@Dissimulazione](https://github.com/Dissimulazione))
+ * Fix mixins not working at end of file ([@ForbesLindesay](http://www.forbeslindesay.co.uk/))
+ * Fix error reporting when mixin block was followed by blank lines ([@ForbesLindesay](http://www.forbeslindesay.co.uk/))
+
+
1.5.0 / 2014-07-23
==================
diff --git a/bin/jade.js b/bin/jade.js
index 6411066..d7552ef 100755
--- a/bin/jade.js
+++ b/bin/jade.js
@@ -34,6 +34,7 @@ program
.option('-D, --no-debug', 'compile without debugging (smaller functions)')
.option('-w, --watch', 'watch files for changes and automatically re-render')
.option('--name-after-file', 'Name the template after the last section of the file path (requires --client and overriden by --name)')
+ .option('--doctype <str>', 'Specify the doctype on the command line (useful if it is not specified by the template)')
program.on('--help', function(){
@@ -92,6 +93,10 @@ options.watch = program.watch;
options.name = program.name;
+// --doctype
+
+options.doctype = program.doctype;
+
// left-over args are file paths
var files = program.args;
diff --git a/component.json b/component.json
index c43dfb4..a3befff 100644
--- a/component.json
+++ b/component.json
@@ -2,7 +2,7 @@
"name": "jade",
"repo": "visionmedia/jade",
"description": "Jade template runtime",
- "version": "1.5.0",
+ "version": "1.7.0",
"keywords": [
"template"
],
@@ -13,4 +13,4 @@
"lib/runtime.js"
],
"main": "lib/runtime.js"
-}
\ No newline at end of file
+}
diff --git a/docs/versions.json b/docs/versions.json
index 9dfc49e..4cc33fc 100644
--- a/docs/versions.json
+++ b/docs/versions.json
@@ -3,5 +3,7 @@
"1.4.0",
"1.4.1",
"1.4.2",
- "1.5.0"
+ "1.5.0",
+ "1.6.0",
+ "1.7.0"
]
\ No newline at end of file
diff --git a/docs/views/api.jade b/docs/views/api.jade
index d4a50b9..8934979 100644
--- a/docs/views/api.jade
+++ b/docs/views/api.jade
@@ -24,6 +24,9 @@ block content
dt filename:
dd.type.string string
dd.description Used in exceptions, and required for relative includes and extends
+ dt doctype:
+ dd.type.string string
+ dd.description If the doctype is not specified as part of the template, you can specify it here. It is sometimes useful to get self-closing tags and remove mirroring of boolean attributes.
dt pretty:
dd.type.boolean boolean
dd.description Adds whitespace to the resulting html to make it easier for a human to read
diff --git a/docs/views/command-line.jade b/docs/views/command-line.jade
index 59b5360..d94f09c 100644
--- a/docs/views/command-line.jade
+++ b/docs/views/command-line.jade
@@ -28,6 +28,7 @@ block content
-c, --client compile function for client-side runtime.js
-D, --no-debug compile without debugging (smaller functions)
-w, --watch watch files for changes and automatically re-render
+ --doctype specify the doctype if it is not already specified by the template
```
### Examples
diff --git a/docs/views/reference.jade b/docs/views/reference.jade
index 280fbe6..9ddc36f 100644
--- a/docs/views/reference.jade
+++ b/docs/views/reference.jade
@@ -17,6 +17,7 @@ block content
+link('extends')
+link('filters')
+link('includes')
+ +link('inheritance')
+link('iteration')
+link('mixins')
+link('plain text')
diff --git a/docs/views/reference/attributes.jade b/docs/views/reference/attributes.jade
index 7b8f557..f037238 100644
--- a/docs/views/reference/attributes.jade
+++ b/docs/views/reference/attributes.jade
@@ -24,13 +24,53 @@ block documentation
+jade
:jadesrc
- var authenticated = true
- body(class=authenticated?'authed':'anon')
+ body(class=authenticated ? 'authed' : 'anon')
.col-lg-6
+html
:htmlsrc
<body class="authed"></body>
- h4#booleanattribs Boolean Attributes
+ p If you have many attributes, you can also spread them across many lines:
+
+ .row(data-control='interactive')
+ .col-lg-6
+ +jade
+ :jadesrc
+ input(
+ type='checkbox'
+ name='agreement'
+ checked
+ )
+ .col-lg-6
+ +html
+ :htmlsrc
+ <input type="checkbox" name="agreement" checked="checked" />
+
+ h2#unescaped Unescaped Attributes
+
+ p By default, all attributes are escaped (replacing special characters with escape sequences) to prevent attacks such as cross site scripting. If you need to use special characters you can use #[code !=] instead of #[code =].
+
+ .row(data-control='interactive')
+ .col-lg-6
+ +jade
+ :jadesrc
+ div(escaped="<code>")
+ div(unescaped!="<code>")
+ .col-lg-6
+ +html
+ :htmlsrc
+ <div escaped="<code>"></div>
+ <div unescaped="<code>"></div>
+
+ .panel.panel-danger
+ .panel-heading Danger
+ .panel-body
+ p.
+ Unescaped buffered code can be dangerous.
+ You must be sure to sanatize any user inputs to avoid
+ #[a(href='http://en.wikipedia.org/wiki/Cross-site_scripting') Cross Site Scripting]
+
+ h2#booleanattribs Boolean Attributes
p Boolean attributes are mirrored by Jade, and accept bools, aka #[code true] or #[code false]. When no value is specified true is assumed.
@@ -119,7 +159,6 @@ block documentation
p IDs may be defined using a <code>#idname</code> syntax:
-
.row(data-control='interactive')
.col-lg-6
+jade
@@ -141,3 +180,38 @@ block documentation
+html
:htmlsrc
<div id="content"></div>
+
+ h2#and-attributes &attributes
+
+ p Pronounced "and attributes", the #[code &attributes] syntax can be used to explode an object into attributes of an element.
+
+ .row(data-control='interactive')
+ .col-lg-6
+ +jade
+ :jadesrc
+ div#foo(data-bar="foo")&attributes({'data-foo': 'bar'})
+ .col-lg-6
+ +html
+ :htmlsrc
+ <div id="foo" data-bar="foo" data-foo="bar"></div>
+
+ p The object does not have to be an object literal. It can also just be a variable that has an object as its value (see also #[a(href="/reference/mixins#attributes") Mixin Attributes])
+
+ .row(data-control='interactive')
+ .col-lg-6
+ +jade
+ :jadesrc
+ - var attributes = {'data-foo': 'bar'};
+ div#foo(data-bar="foo")&attributes(attributes)
+ .col-lg-6
+ +html
+ :htmlsrc
+ <div id="foo" data-bar="foo" data-foo="bar"></div>
+ .panel.panel-danger
+ .panel-heading Danger
+ .panel-body
+ p.
+ Attributes applied using #[code &attributes] are not automatically escaped.
+ You must be sure to sanatize any user inputs to avoid
+ #[a(href='http://en.wikipedia.org/wiki/Cross-site_scripting') Cross Site Scripting].
+ This is done for you if you are passing in #[code attributes] from a mixin call.
diff --git a/docs/views/reference/code.jade b/docs/views/reference/code.jade
index 9c8e193..a68d6a8 100644
--- a/docs/views/reference/code.jade
+++ b/docs/views/reference/code.jade
@@ -1,7 +1,7 @@
extends ../reference.jade
block documentation
- h1 Code
+ h1 Code & Interpolation
p Jade makes it possible to write inline JavaScript code in your templates. There are three types of code.
@@ -84,3 +84,45 @@ block documentation
Unescaped buffered code can be dangerous.
You must be sure to sanatize any user inputs to avoid
#[a(href='http://en.wikipedia.org/wiki/Cross-site_scripting') Cross Site Scripting]
+
+ h2 Interpolation
+
+ p.
+ Both plain-text and piped-text support interpolation. The following will output the user.name in the paragraph:
+
+ .row(data-control='interactive')
+ .col-lg-6
+ +jade
+ :jadesrc
+ - var user = {name: 'Forbes Lindesay'}
+ p Welcome \#{user.name}
+ .col-lg-6
+ +html
+ :htmlsrc
+ <p>Welcome Forbes Lindesay</p>
+
+ p It is generally recommended that you use #[code =] for buffering code unless it is a small amount of code in a large block.
+
+ h2 Unescaped Interpolation
+
+ p You can also use unescaped interpolation to output HTML:
+
+ .row(data-control='interactive')
+ .col-lg-6
+ +jade
+ :jadesrc
+ - var user = {name: '<strong>Forbes Lindesay</strong>'}
+ p Welcome \#{user.name}
+ p Welcome \!{user.name}
+ .col-lg-6
+ +html
+ :htmlsrc
+ <p>Welcome <strong>Forbes Lindesay</strong></p>
+ <p>Welcome <strong>Forbes Lindesay</strong></p>
+ .panel.panel-danger
+ .panel-heading Danger
+ .panel-body
+ p.
+ Unescaped buffered code can be dangerous.
+ You must be sure to sanatize any user inputs to avoid
+ #[a(href='http://en.wikipedia.org/wiki/Cross-site_scripting') Cross Site Scripting]
diff --git a/docs/views/reference/comments.jade b/docs/views/reference/comments.jade
index 9d54362..fb57c10 100644
--- a/docs/views/reference/comments.jade
+++ b/docs/views/reference/comments.jade
@@ -60,7 +60,7 @@ block documentation
p.
Jade does not have any special syntax for conditional comments.
- If your line begins with #[code >] then it is treated as plain text.
+ If your line begins with #[code <] then it is treated as plain text.
So just use normal HTML syle conditional comments:
.row(data-control='interactive')
diff --git a/docs/views/reference/doctype.jade b/docs/views/reference/doctype.jade
index 17b5de7..4ac2b93 100644
--- a/docs/views/reference/doctype.jade
+++ b/docs/views/reference/doctype.jade
@@ -1,7 +1,7 @@
extends ../reference.jade
block documentation
- h1 doctype
+ h1 Doctype
.row(data-control='interactive')
.col-lg-6
+jade
@@ -11,16 +11,25 @@ block documentation
+html
:htmlsrc
<!DOCTYPE html>
+
+ h2 Doctype Shortcuts
+
p There are shortcuts for commonly used doctypes:
dl
+ dt doctype html
+ dd
+ pre
+ code= '<!DOCTYPE html>'
each doctype, key in doctypes
if key != '5' && key != 'default'
- dt= key
+ dt= 'doctype ' + key
dd
pre
code= doctype
+ h2 Custom Doctypes
+
p You can also use your own literal custom doctype:
.row(data-control='interactive')
@@ -32,3 +41,31 @@ block documentation
+html
:htmlsrc
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN">
+
+ h2 Doctype Option
+
+ p.
+ The doctype affects compilation in some other cases, for example self closing tags
+ and #[a(href="http://localhost:3000/reference/attributes#booleanattribs") boolean attributes]).
+ For this reason, you might sometimes want to specify it manually. You can do this via the
+ #[code doctype] option. e.g.
+
+
+ +js
+ :jssrc
+ var jade = require('./');
+
+ // Compile a function
+ var fn = jade.compile('img(src="foo.png")', {doctype: 'xml'});
+
+ // Render the function
+ var html = fn({});
+ // => '<img src="foo.png"></img>'
+
+ // Compile a function
+ var fn = jade.compile('img(src="foo.png")', {doctype: 'html'});
+
+ // Render the function
+ var html = fn({});
+ // => '<img src="foo.png">'
+
diff --git a/docs/views/reference/extends.jade b/docs/views/reference/extends.jade
index cc08f3b..f4d6b27 100644
--- a/docs/views/reference/extends.jade
+++ b/docs/views/reference/extends.jade
@@ -47,4 +47,4 @@ block documentation
.panel-heading Note
.panel-body.
You can have multiple levels of inheritance, allowing you to create
- powerful higherachies of templates.
+ powerful hierarchies of templates.
diff --git a/docs/views/reference/inheritance.jade b/docs/views/reference/inheritance.jade
new file mode 100644
index 0000000..83050e8
--- /dev/null
+++ b/docs/views/reference/inheritance.jade
@@ -0,0 +1,104 @@
+extends ../reference.jade
+
+block documentation
+ h1 Template inheritance
+
+ p.
+ Jade supports template inheritance via the #[code block] and #[code extends] keywords. A block is simply a "block"
+ of Jade that may be replaced within a child template, this process is recursive.
+
+ p.
+ Jade blocks can provide default content if desired, however optional as shown below by `block scripts`, `block content`, and `block foot`.
+
+ p layout.jade
+ +jade
+ :jadesrc
+ html
+ head
+ title My Site - \#{title}
+ block scripts
+ script(src='/jquery.js')
+ body
+ block content
+ block foot
+ #footer
+ p some footer content
+
+ p Now to extend the layout, simply create a new file and use the `extends` directive as shown below, giving the path (with or without the .jade extension). You may now define one or more blocks that will override the parent block content, note that here the `foot` block is _not_ redefined and will output "some footer content".
+
+ p page-a.jade
+ +jade
+ :jadesrc
+ extends ./layout.jade
+
+ block scripts
+ script(src='/jquery.js')
+ script(src='/pets.js')
+
+ block content
+ h1= title
+ each pet in pets
+ include pet
+
+ p.
+ It's also possible to override a block to provide additional blocks, as shown in the following example where `content` now exposes a `sidebar` and `primary` block for overriding, or the child template could override `content` all together.
+
+ p sub-layout.jade
+ +jade
+ :jadesrc
+ extends ./layout.jade
+
+ block content
+ .sidebar
+ block sidebar
+ p nothing
+ .primary
+ block primary
+ p nothing
+ p page-b.jade
+ +jade
+ :jadesrc
+ extends ./sub-layout.jade
+
+ block content
+ .sidebar
+ block sidebar
+ p nothing
+ .primary
+ block primary
+ p nothing
+
+
+ h2 Block append / prepend
+
+ p Jade allows you to #[em replace] (default), #[em prepend], or #[em append] blocks. Suppose for example you have default scripts in a "head" block that you wish to utilize on #[em every] page, you might do this:
+
+ +jade
+ :jadesrc
+ html
+ head
+ block head
+ script(src='/vendor/jquery.js')
+ script(src='/vendor/caustic.js')
+ body
+ block content
+
+ p Now suppose you have a page of your application for a JavaScript game, you want some game related scripts as well as these defaults, you can simply `append` the block:
+
+ +jade
+ :jadesrc
+ extends layout
+
+ block append head
+ script(src='/vendor/three.js')
+ script(src='/game.js')
+
+ p When using `block append` or `block prepend` the `block` is optional:
+
+ +jade
+ :jadesrc
+ extends layout
+
+ append head
+ script(src='/vendor/three.js')
+ script(src='/game.js')
diff --git a/docs/views/reference/iteration.jade b/docs/views/reference/iteration.jade
index 1c79e68..06706a3 100644
--- a/docs/views/reference/iteration.jade
+++ b/docs/views/reference/iteration.jade
@@ -65,7 +65,25 @@ block documentation
<li>3: three</li>
</ul>
- p The object or array to iterate over is just plain JavaScript so it can be a variable or the result of a function call as well.
+ p The object or array to iterate over is just plain JavaScript so it can be a variable or the result of a function call or almost anything else. e.g.
+
+
+ .row(data-control='interactive')
+ .col-lg-6
+ +jade
+ :jadesrc
+ - var values = [];
+ ul
+ each val in values.length ? values : ['There are no values']
+ li= val
+ .col-lg-6
+ +html
+ :htmlsrc
+ <ul>
+ <li>There are no values</li>
+ </ul>
+
+ p You can also use #[code for] as an alias of #[code each].
h2 while
diff --git a/docs/views/reference/mixins.jade b/docs/views/reference/mixins.jade
index 0553365..9981147 100644
--- a/docs/views/reference/mixins.jade
+++ b/docs/views/reference/mixins.jade
@@ -53,7 +53,7 @@ block documentation
<li class="pet">pig</li>
</ul>
- h2 Mixin Blocks
+ h2#blocks Mixin Blocks
p Mixins can also take a block of jade to act as the content:
@@ -93,7 +93,7 @@ block documentation
</div>
</div>
- h2 Mixin Attributes
+ h2#attributes Mixin Attributes
p Mixins also get an implicit attributes argument taken from the attributes passed to the mixin:
@@ -109,9 +109,49 @@ block documentation
.col-lg-6
+html
:htmlsrc
- <a class="btn" href="/foo">foo</a>
+ <a href="/foo" class="btn" >foo</a>
+
.panel.panel-info
.panel-heading Note
.panel-body.
The values in #[code attributes] are already escaped so you should
- use #[code !=] to avoid escaping them a second time.
+ use #[code !=] to avoid escaping them a second time (see also #[a(href="/reference/attributes#unescaped") unescaped attributes]).
+
+ p You can also use with #[code &attributes] (see also #[a(href="/reference/attributes#and-attributes") &attributes])
+
+ .row(data-control='interactive')
+ .col-lg-6
+ +jade
+ :jadesrc
+ mixin link(href, name)
+ a(href=href)&attributes(attributes)= name
+
+ +link('/foo', 'foo')(class="btn")
+ .col-lg-6
+ +html
+ :htmlsrc
+ <a href="/foo" class="btn" >foo</a>
+
+ h2 Rest Arguments
+
+ p You can write mixins that take an unknown number of arguments using the "rest arguments" syntax. e.g.
+
+ .row(data-control='interactive')
+ .col-lg-6
+ +jade
+ :jadesrc
+ mixin list(id, ...items)
+ ul(id=id)
+ each item in items
+ li= item
+
+ +list('my-list', 1, 2, 3, 4)
+ .col-lg-6
+ +html
+ :htmlsrc
+ <ul id="my-list">
+ <li>1</li>
+ <li>2</li>
+ <li>3</li>
+ <li>4</li>
+ </ul>
diff --git a/docs/views/reference/tags.jade b/docs/views/reference/tags.jade
index a43679f..3dedd27 100644
--- a/docs/views/reference/tags.jade
+++ b/docs/views/reference/tags.jade
@@ -47,3 +47,19 @@ block documentation
+html
:htmlsrc
<a><img/></a>
+
+ h2 Self Closing Tags
+
+ p Tags such as #[code img], #[code meta], #[code link] and so on are automatically self-closing (unless you use the xml doctype). You can also explicitly self close a tag by simply appending the #[code /] character. Only do this if you know what you're doing
+
+ .row(data-control='interactive')
+ .col-lg-6
+ +jade
+ :jadesrc
+ foo/
+ foo(bar='baz')/
+ .col-lg-6
+ +html
+ :htmlsrc
+ <foo/>
+ <foo bar="baz"/>
diff --git a/jade-language.md b/jade-language.md
deleted file mode 100644
index a5960fd..0000000
--- a/jade-language.md
+++ /dev/null
@@ -1,1023 +0,0 @@
-
-<a name="a6"/>
-## Syntax
-
-<a name="a6-2"/>
-### Tags
-
-A tag is simply a leading word:
-
-```jade
-html
-```
-
-for example is converted to `<html></html>`
-
-tags can also have ids:
-
-```jade
-div#container
-```
-
-which would render `<div id="container"></div>`
-
-how about some classes?
-
-```jade
-div.user-details
-```
-
-renders `<div class="user-details"></div>`
-
-multiple classes? _and_ an id? sure:
-
-```jade
-div#foo.bar.baz
-```
-
-renders `<div id="foo" class="bar baz"></div>`
-
-div div div sure is annoying, how about:
-
-```jade
-#foo
-.bar
-```
-
-which is syntactic sugar for what we have already been doing, and outputs:
-
-```html
-<div id="foo"></div><div class="bar"></div>
-```
-
-<a name="a6-3"/>
-### Tag Text
-
-Simply place some content after the tag:
-
-```jade
-p wahoo!
-```
-
-renders `<p>wahoo!</p>`.
-
-well cool, but how about large bodies of text:
-
-```jade
-p
- | foo bar baz
- | rawr rawr
- | super cool
- | go jade go
-```
-
-renders `<p>foo bar baz rawr.....</p>`
-
-interpolation? yup! both types of text can utilize interpolation,
-if we passed `{ name: 'tj', email: 'tj at vision-media.ca' }` to the compiled function we can do the following:
-
-```jade
-#user #{name} <#{email}>
-```
-
-outputs `<div id="user">tj <tj at vision-media.ca></div>`
-
-Actually want `#{}` for some reason? escape it!
-
-```jade
-p \#{something}
-```
-
-now we have `<p>#{something}</p>`
-
-We can also utilize the unescaped variant `!{html}`, so the following
-will result in a literal script tag:
-
-```jade
-- var html = "<script></script>"
-| !{html}
-```
-
-Nested tags that also contain text can optionally use a text block:
-
-```jade
-label
- | Username:
- input(name='user[name]')
-```
-
-or immediate tag text:
-
-```jade
-label Username:
- input(name='user[name]')
-```
-
-As an alternative, we may use a trailing `.` to indicate a text block, for example:
-
-```jade
-p.
- foo asdf
- asdf
- asdfasdfaf
- asdf
- asd.
-```
-
-outputs:
-
-```html
-<p>foo asdf
-asdf
- asdfasdfaf
- asdf
-asd.
-</p>
-```
-
-This however differs from a trailing `.` followed by a space, which although is ignored by the Jade parser, tells Jade that this period is a literal:
-
-```jade
-p .
-```
-
-outputs:
-
-```html
-<p>.</p>
-```
-
-It should be noted that text blocks should be doubled escaped. For example if you desire the following output.
-
-```html
-<p>foo\bar</p>
-```
-
-use:
-
-```jade
-p.
- foo\\bar
-```
-
-<a name="a6-4"/>
-### Comments
-
-Single line comments currently look the same as JavaScript comments,
-aka `//` and must be placed on their own line:
-
-```jade
-// just some paragraphs
-p foo
-p bar
-```
-
-would output
-
-```html
-<!-- just some paragraphs -->
-<p>foo</p>
-<p>bar</p>
-```
-
-Jade also supports unbuffered comments, by simply adding a hyphen:
-
-```jade
-//- will not output within markup
-p foo
-p bar
-```
-
-outputting
-
-```html
-<p>foo</p>
-<p>bar</p>
-```
-
-<a name="a6-5"/>
-### Block Comments
-
- A block comment is legal as well:
-
-```jade
-body
- //
- #content
- h1 Example
-```
-
-outputting
-
-```html
-<body>
- <!--
- <div id="content">
- <h1>Example</h1>
- </div>
- -->
-</body>
-```
-
-Jade supports conditional-comments as well, for example:
-
-```jade
-head
- //if lt IE 8
- script(src='/ie-sucks.js')
-```
-
-outputs:
-
-```html
-<head>
- <!--[if lt IE 8]>
- <script src="/ie-sucks.js"></script>
- <![endif]-->
-</head>
-```
-
-<a name="a6-6"/>
-### Nesting
-
- Jade supports nesting to define the tags in a natural way:
-
-```jade
-ul
- li.first
- a(href='#') foo
- li
- a(href='#') bar
- li.last
- a(href='#') baz
-```
-
-<a name="a6-7"/>
-### Block Expansion
-
- Block expansion allows you to create terse single-line nested tags,
- the following example is equivalent to the nesting example above.
-
-```jade
-ul
- li.first: a(href='#') foo
- li: a(href='#') bar
- li.last: a(href='#') baz
-```
-
-<a name="a6-8"/>
-### Case
-
- The case statement takes the following form:
-
-```jade
-html
- body
- friends = 10
- case friends
- when 0
- p you have no friends
- when 1
- p you have a friend
- default
- p you have #{friends} friends
-```
-
- Block expansion may also be used:
-
-```jade
-friends = 5
-
-html
- body
- case friends
- when 0: p you have no friends
- when 1: p you have a friend
- default: p you have #{friends} friends
-```
-
-<a name="a6-9"/>
-### Attributes
-
-Jade currently supports `(` and `)` as attribute delimiters.
-
-```jade
-a(href='/login', title='View login page') Login
-```
-
-When a value is `undefined` or `null` the attribute is _not_ added,
-so this is fine, it will not compile `something="null"`.
-
-```jade
-div(something=null)
-```
-
-Boolean attributes are also supported:
-
-```jade
-input(type="checkbox", checked)
-```
-
-Boolean attributes with code will only output the attribute when `true`:
-
-```jade
-input(type="checkbox", checked=someValue)
-```
-
-Multiple lines work too:
-
-```jade
-input(type='checkbox',
- name='agreement',
- checked)
-```
-
-Multiple lines without the comma work fine:
-
-```jade
-input(type='checkbox'
- name='agreement'
- checked)
-```
-
-Funky whitespace? fine:
-
-```jade
-input(
- type='checkbox'
- name='agreement'
- checked)
-```
-
-Colons work:
-
-```jade
-rss(xmlns:atom="atom")
-```
-
-Suppose we have the `user` local `{ id: 12, name: 'tobi' }`
-and we wish to create an anchor tag with `href` pointing to "/user/12"
-we could use regular javascript concatenation:
-
-```jade
-a(href='/user/' + user.id)= user.name
-```
-
-or we could use jade's interpolation, which I added because everyone
-using Ruby or CoffeeScript seems to think this is legal js..:
-
-```jade
-a(href='/user/#{user.id}')= user.name
-```
-
-The `class` attribute is special-cased when an array is given,
-allowing you to pass an array such as `bodyClasses = ['user', 'authenticated']` directly:
-
-```jade
-body(class=bodyClasses)
-```
-
-<a name="a6-10"/>
-### HTML
-
- Inline html is fine, we can use the pipe syntax to
- write arbitrary text, in this case some html:
-
-```jade
-html
- body
- | <h1>Title</h1>
- | <p>foo bar baz</p>
-```
-
- Or we can use the trailing `.` to indicate to Jade that we
- only want text in this block, allowing us to omit the pipes:
-
-```jade
-html
- body.
- <h1>Title</h1>
- <p>foo bar baz</p>
-```
-
- Both of these examples yield the same result:
-
-```html
-<html><body><h1>Title</h1>
-<p>foo bar baz</p>
-</body></html>
-```
-
- The same rule applies for anywhere you can have text
- in jade, raw html is fine:
-
-```jade
-html
- body
- h1 User <em>#{name}</em>
-```
-
-<a name="a6-11"/>
-### Doctypes
-
-To add a doctype simply use `!!!`, or `doctype` followed by an optional value:
-
-```jade
-!!!
-```
-
-or
-
-```jade
-doctype
-```
-
-Will output the _html 5_ doctype, however:
-
-```jade
-!!! transitional
-```
-
-Will output the _transitional_ doctype.
-
-Doctypes are case-insensitive, so the following are equivalent:
-
-```jade
-doctype Basic
-doctype basic
-```
-
-it's also possible to simply pass a doctype literal:
-
-```jade
-doctype html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
-```
-
-yielding:
-
-```html
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN">
-```
-
-Below are the doctypes defined by default, which can easily be extended:
-
-```js
-var doctypes = exports.doctypes = {
- '5': '<!DOCTYPE html>',
- 'default': '<!DOCTYPE html>',
- 'xml': '<?xml version="1.0" encoding="utf-8" ?>',
- 'transitional': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
- 'strict': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
- 'frameset': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
- '1.1': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
- 'basic': '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
- 'mobile': '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">'
-};
-```
-
-To alter the default simply change:
-
-```js
-jade.doctypes.default = 'whatever you want';
-```
-
-<a name="a7"/>
-## Filters
-
-Filters are prefixed with `:`, for example `:markdown` and
-pass the following block of text to an arbitrary function for processing. View the _features_
-at the top of this document for available filters.
-
-```jade
-body
- :markdown
- Woah! jade _and_ markdown, very **cool**
- we can even link to [stuff](http://google.com)
-```
-
-Renders:
-
-```html
-<body><p>Woah! jade <em>and</em> markdown, very <strong>cool</strong> we can even link to <a href="http://google.com">stuff</a></p></body>
-```
-
-<a name="a8"/>
-## Code
-
-Jade currently supports three classifications of executable code. The first
-is prefixed by `-`, and is not buffered:
-
-```jade
-- var foo = 'bar';
-```
-
-This can be used for conditionals, or iteration:
-
-```jade
-- for (var key in obj)
- p= obj[key]
-```
-
-Due to Jade's buffering techniques the following is valid as well:
-
-```jade
-- if (foo)
- ul
- li yay
- li foo
- li worked
-- else
- p oh no! didnt work
-```
-
-Hell, even verbose iteration:
-
-```jade
-- if (items.length)
- ul
- - items.forEach(function(item){
- li= item
- - })
-```
-
-Anything you want!
-
-Next up we have _escaped_ buffered code, which is used to
-buffer a return value, which is prefixed by `=`:
-
-```jade
-- var foo = 'bar'
-= foo
-h1= foo
-```
-
-Which outputs `bar<h1>bar</h1>`. Code buffered by `=` is escaped
-by default for security, however to output unescaped return values
-you may use `!=`:
-
-```jade
-p!= aVarContainingMoreHTML
-```
-
- Jade also has designer-friendly variants, making the literal JavaScript
- more expressive and declarative. For example the following assignments
- are equivalent, and the expression is still regular javascript:
-
-```jade
-- var foo = 'foo ' + 'bar'
-foo = 'foo ' + 'bar'
-```
-
- Likewise Jade has first-class `if`, `else if`, `else`, `until`, `while`, `unless` among others, however you must remember that the expressions are still regular javascript:
-
-```jade
-if foo == 'bar'
- ul
- li yay
- li foo
- li worked
-else
- p oh no! didnt work
-```
-
-<a name="a9"/>
-## Iteration
-
- Along with vanilla JavaScript Jade also supports a subset of
- constructs that allow you to create more designer-friendly templates,
- one of these constructs is `each`, taking the form:
-
-```jade
-each VAL[, KEY] in OBJ
-```
-
-An example iterating over an array:
-
-```jade
-- var items = ["one", "two", "three"]
-each item in items
- li= item
-```
-
-outputs:
-
-```html
-<li>one</li>
-<li>two</li>
-<li>three</li>
-```
-
-iterating an array with index:
-
-```jade
-items = ["one", "two", "three"]
-each item, i in items
- li #{item}: #{i}
-```
-
-outputs:
-
-```html
-<li>one: 0</li>
-<li>two: 1</li>
-<li>three: 2</li>
-```
-
-iterating an object's keys and values:
-
-```jade
-obj = { foo: 'bar' }
-each val, key in obj
- li #{key}: #{val}
-```
-
-would output `<li>foo: bar</li>`
-
-Internally Jade converts these statements to regular
-JavaScript loops such as `users.forEach(function(user){`,
-so lexical scope and nesting applies as it would with regular
-JavaScript:
-
-```jade
-each user in users
- each role in user.roles
- li= role
-```
-
- You may also use `for` if you prefer:
-
-```jade
-for user in users
- for role in user.roles
- li= role
-```
-
-<a name="a10"/>
-## Conditionals
-
- Jade conditionals are equivalent to those using the code (`-`) prefix,
- however allow you to ditch parenthesis to become more designer friendly,
- however keep in mind the expression given is _regular_ JavaScript:
-
-```jade
-for user in users
- if user.role == 'admin'
- p #{user.name} is an admin
- else
- p= user.name
-```
-
- is equivalent to the following using vanilla JavaScript literals:
-
-```jade
-for user in users
- - if (user.role == 'admin')
- p #{user.name} is an admin
- - else
- p= user.name
-```
-
- Jade also provides `unless` which is equivalent to `if (!(expr))`:
-
-```jade
-for user in users
- unless user.isAnonymous
- p
- | Click to view
- a(href='/users/' + user.id)= user.name
-```
-
-<a name="a11"/>
-## Template inheritance
-
- Jade supports template inheritance via the `block` and `extends` keywords. A block is simply a "block" of Jade that may be replaced within a child template, this process is recursive. To activate template inheritance in Express 2.x you must add: `app.set('view options', { layout: false });`.
-
- Jade blocks can provide default content if desired, however optional as shown below by `block scripts`, `block content`, and `block foot`.
-
-```jade
-html
- head
- title My Site - #{title}
- block scripts
- script(src='/jquery.js')
- body
- block content
- block foot
- #footer
- p some footer content
-```
-
- Now to extend the layout, simply create a new file and use the `extends` directive as shown below, giving the path (with or without the .jade extension). You may now define one or more blocks that will override the parent block content, note that here the `foot` block is _not_ redefined and will output "some footer content".
-
-```jade
-extends layout
-
-block scripts
- script(src='/jquery.js')
- script(src='/pets.js')
-
-block content
- h1= title
- each pet in pets
- include pet
-```
-
- It's also possible to override a block to provide additional blocks, as shown in the following example where `content` now exposes a `sidebar` and `primary` block for overriding, or the child template could override `content` all together.
-
-```jade
-extends regular-layout
-
-block content
- .sidebar
- block sidebar
- p nothing
- .primary
- block primary
- p nothing
-```
-
-<a name="a12"/>
-## Block append / prepend
-
- Jade allows you to _replace_ (default), _prepend_, or _append_ blocks. Suppose for example you have default scripts in a "head" block that you wish to utilize on _every_ page, you might do this:
-
-```jade
-html
- head
- block head
- script(src='/vendor/jquery.js')
- script(src='/vendor/caustic.js')
- body
- block content
-```
-
- Now suppose you have a page of your application for a JavaScript game, you want some game related scripts as well as these defaults, you can simply `append` the block:
-
-```jade
-extends layout
-
-block append head
- script(src='/vendor/three.js')
- script(src='/game.js')
-```
-
- When using `block append` or `block prepend` the `block` is optional:
-
-```jade
-extends layout
-
-append head
- script(src='/vendor/three.js')
- script(src='/game.js')
-```
-
-<a name="a13"/>
-## Includes
-
- Includes allow you to statically include chunks of Jade,
- or other content like css, or html which lives in separate files. The classical example is including a header and footer. Suppose we have the following directory structure:
-
- ./layout.jade
- ./includes/
- ./head.jade
- ./foot.jade
-
-and the following _layout.jade_:
-
-```jade
-html
- include includes/head
- body
- h1 My Site
- p Welcome to my super amazing site.
- include includes/foot
-```
-
-both includes _includes/head_ and _includes/foot_ are
-read relative to the `filename` option given to _layout.jade_,
-which should be an absolute path to this file, however Express
-does this for you. Include then parses these files, and injects
-the AST produced to render what you would expect:
-
-```html
-<html>
- <head>
- <title>My Site</title>
- <script src="/javascripts/jquery.js">
- </script><script src="/javascripts/app.js"></script>
- </head>
- <body>
- <h1>My Site</h1>
- <p>Welcome to my super lame site.</p>
- <div id="footer">
- <p>Copyright>(c) foobar</p>
- </div>
- </body>
-</html>
-```
-
-As mentioned `include` can be used to include other content
-such as html or css. By providing an explicit filter name
-with `include:`, Jade will read that file in, apply the
-[filter](#a7), and insert that content into the output.
-
-```jade
-html
- head
- //- css and js have simple filters that wrap them in
- <style> and <script> tags, respectively
- include stylesheet.css
- include script.js
- body
- //- use the "markdown" filter to convert Markdown to HTML
- include:markdown introduction.markdown
- //- html files have no filter and are included verbatim
- include content.html
-```
-
- Include directives may also accept a block, in which case the
- the given block will be appended to the _last_ block defined
- in the file. For example if `head.jade` contains:
-
-```jade
-head
- script(src='/jquery.js')
-```
-
- We may append values by providing a block to `include head`
- as shown below, adding the two scripts.
-
-```jade
-html
- include head
- script(src='/foo.js')
- script(src='/bar.js')
- body
- h1 test
-```
-
- You may also `yield` within an included template, allowing you to explicitly mark where the block given to `include` will be placed. Suppose for example you wish to prepend scripts rather than append, you might do the following:
-
-```jade
-head
- yield
- script(src='/jquery.js')
- script(src='/jquery.ui.js')
-```
-
- Since included Jade is parsed and literally merges the AST, lexically scoped variables function as if the included Jade was written right in the same file. This means `include` may be used as sort of partial, for example suppose we have `user.jade` which utilizes a `user` variable.
-
-```jade
-h1= user.name
-p= user.occupation
-```
-
-We could then simply `include user` while iterating users, and since the `user` variable is already defined within the loop the included template will have access to it.
-
-```jade
-users = [{ name: 'Tobi', occupation: 'Ferret' }]
-
-each user in users
- .user
- include user
-```
-
-yielding:
-
-```html
-<div class="user">
- <h1>Tobi</h1>
- <p>Ferret</p>
-</div>
-```
-
-If we wanted to expose a different variable name as `user` since `user.jade` references that name, we could simply define a new variable as shown here with `user = person`:
-
-```jade
-each person in users
- .user
- user = person
- include user
-```
-
-<a name="a14"/>
-## Mixins
-
- Mixins are converted to regular JavaScript functions in
- the compiled template that Jade constructs. Mixins may
- take arguments, though not required:
-
-```jade
-mixin list
- ul
- li foo
- li bar
- li baz
-```
-
- Utilizing a mixin without args looks similar, just without a block:
-
-```jade
-h2 Groceries
-mixin list
-```
-
- Mixins may take one or more arguments as well, the arguments
- are regular javascripts expressions, so for example the following:
-
-```jade
-mixin pets(pets)
- ul.pets
- - each pet in pets
- li= pet
-
-mixin profile(user)
- .user
- h2= user.name
- mixin pets(user.pets)
-```
-
- Would yield something similar to the following html:
-
-```html
-<div class="user">
- <h2>tj</h2>
- <ul class="pets">
- <li>tobi</li>
- <li>loki</li>
- <li>jane</li>
- <li>manny</li>
- </ul>
-</div>
-```
-
-<a name="a15"/>
-## Generated Output
-
- Suppose we have the following Jade:
-
-```jade
-- var title = 'yay'
-h1.title #{title}
-p Just an example
-```
-
- When the `compileDebug` option is not explicitly `false`, Jade
- will compile the function instrumented with `__.lineno = n;`, which
- in the event of an exception is passed to `rethrow()` which constructs
- a useful message relative to the initial Jade input.
-
-```js
-function anonymous(locals) {
- var __ = { lineno: 1, input: "- var title = 'yay'\nh1.title #{title}\np Just an example", filename: "testing/test.js" };
- var rethrow = jade.rethrow;
- try {
- var attrs = jade.attrs, escape = jade.escape;
- var buf = [];
- with (locals || {}) {
- var interp;
- __.lineno = 1;
- var title = 'yay'
- __.lineno = 2;
- buf.push('<h1');
- buf.push(attrs({ "class": ('title') }));
- buf.push('>');
- buf.push('' + escape((interp = title) == null ? '' : interp) + '');
- buf.push('</h1>');
- __.lineno = 3;
- buf.push('<p>');
- buf.push('Just an example');
- buf.push('</p>');
- }
- return buf.join("");
- } catch (err) {
- rethrow(err, __.input, __.filename, __.lineno);
- }
-}
-```
-
-When the `compileDebug` option _is_ explicitly `false`, this instrumentation
-is stripped, which is very helpful for light-weight client-side templates. Combining Jade's options with the `./runtime.js` file in this repo allows you
-to toString() compiled templates and avoid running the entire Jade library on
-the client, increasing performance, and decreasing the amount of JavaScript
-required.
-
-```js
-function anonymous(locals) {
- var attrs = jade.attrs, escape = jade.escape;
- var buf = [];
- with (locals || {}) {
- var interp;
- var title = 'yay'
- buf.push('<h1');
- buf.push(attrs({ "class": ('title') }));
- buf.push('>');
- buf.push('' + escape((interp = title) == null ? '' : interp) + '');
- buf.push('</h1>');
- buf.push('<p>');
- buf.push('Just an example');
- buf.push('</p>');
- }
- return buf.join("");
-}
-```
\ No newline at end of file
diff --git a/jade.md b/jade.md
deleted file mode 100644
index 051dc03..0000000
--- a/jade.md
+++ /dev/null
@@ -1,510 +0,0 @@
-
-# Jade
-
- The jade template engine for node.js
-
-## Synopsis
-
- jade [-h|--help] [-v|--version] [-o|--obj STR]
- [-O|--out DIR] [-p|--path PATH] [-P|--pretty]
- [-c|--client] [-D|--no-debug]
-
-## Examples
-
- translate jade the templates dir
-
- $ jade templates
-
- create {foo,bar}.html
-
- $ jade {foo,bar}.jade
-
- jade over stdio
-
- $ jade < my.jade > my.html
-
- jade over s
-
- $ echo "h1 Jade!" | jade
-
- foo, bar dirs rendering to /tmp
-
- $ jade foo bar --out /tmp
-
- compile client-side templates without debugging
- instrumentation, making the output javascript
- very light-weight. This requires runtime.js
- in your projects.
-
- $ jade --client --no-debug < my.jade
-
-## Tags
-
- Tags are simply nested via whitespace, closing
- tags defined for you. These indents are called "blocks".
-
- ul
- li
- a Foo
- li
- a Bar
-
- You may have several tags in one "block":
-
- ul
- li
- a Foo
- a Bar
- a Baz
-
-## Self-closing Tags
-
- Some tags are flagged as self-closing by default, such
- as `meta`, `link`, and so on. To explicitly self-close
- a tag simply append the `/` character:
-
- foo/
- foo(bar='baz')/
-
- Would yield:
-
- <foo/>
- <foo bar="baz"/>
-
-## Attributes
-
- Tag attributes look similar to HTML, however
- the values are regular JavaScript, here are
- some examples:
-
- a(href='google.com') Google
- a(class='button', href='google.com') Google
-
- As mentioned the attribute values are just JavaScript,
- this means ternary operations and other JavaScript expressions
- work just fine:
-
- body(class=user.authenticated ? 'authenticated' : 'anonymous')
- a(href=user.website || 'http://google.com')
-
- Multiple lines work too:
-
- input(type='checkbox',
- name='agreement',
- checked)
-
- Multiple lines without the comma work fine:
-
- input(type='checkbox'
- name='agreement'
- checked)
-
- Funky whitespace? fine:
-
- input(
- type='checkbox'
- name='agreement'
- checked)
-
-## Boolean attributes
-
- Boolean attributes are mirrored by Jade, and accept
- bools, aka _true_ or _false_. When no value is specified
- _true_ is assumed. For example:
-
- input(type="checkbox", checked)
- // => "<input type="checkbox" checked="checked" />"
-
- For example if the checkbox was for an agreement, perhaps `user.agreed`
- was _true_ the following would also output 'checked="checked"':
-
- input(type="checkbox", checked=user.agreed)
-
-## Class attributes
-
- The _class_ attribute accepts an array of classes,
- this can be handy when generated from a javascript
- function etc:
-
- classes = ['foo', 'bar', 'baz']
- a(class=classes)
- // => "<a class="foo bar baz"></a>"
-
-## Class literal
-
- Classes may be defined using a ".CLASSNAME" syntax:
-
- .button
- // => "<div class="button"></div>"
-
- Or chained:
-
- .large.button
- // => "<div class="large button"></div>"
-
- The previous defaulted to divs, however you
- may also specify the tag type:
-
- h1.title My Title
- // => "<h1 class="title">My Title</h1>"
-
-## Id literal
-
- Much like the class literal there's an id literal:
-
- #user-1
- // => "<div id="user-1"></div>"
-
- Again we may specify the tag as well:
-
- ul#menu
- li: a(href='/home') Home
- li: a(href='/store') Store
- li: a(href='/contact') Contact
-
- Finally all of these may be used in any combination,
- the following are all valid tags:
-
- a.button#contact(style: 'color: red') Contact
- a.button(style: 'color: red')#contact Contact
- a(style: 'color: red').button#contact Contact
-
-## Block expansion
-
- Jade supports the concept of "block expansion", in which
- using a trailing ":" after a tag will inject a block:
-
- ul
- li: a Foo
- li: a Bar
- li: a Baz
-
-## Text
-
- Arbitrary text may follow tags:
-
- p Welcome to my site
-
- yields:
-
- <p>Welcome to my site</p>
-
-## Pipe text
-
- Another form of text is "pipe" text. Pipes act
- as the text margin for large bodies of text.
-
- p
- | This is a large
- | body of text for
- | this tag.
- |
- | Nothing too
- | exciting.
-
- yields:
-
- <p>This is a large
- body of text for
- this tag.
-
- Nothing too
- exciting.
- </p>
-
- Using pipes we can also specify regular Jade tags
- within the text:
-
- p
- | Click to visit
- a(href='http://google.com') Google
- | if you want.
-
-## Text only tags
-
- As an alternative to pipe text you may add
- a trailing "." to indicate that the block
- contains nothing but plain-text, no tags:
-
- p.
- This is a large
- body of text for
- this tag.
-
- Nothing too
- exciting.
-
- Some tags are text-only by default, for example
- _script_, _textarea_, and _style_ tags do not
- contain nested HTML so Jade implies the trailing ".":
-
- script
- if (foo) {
- bar();
- }
-
- style
- body {
- padding: 50px;
- font: 14px Helvetica;
- }
-
-## Template script tags
-
- Sometimes it's useful to define HTML in script
- tags using Jade, typically for client-side templates.
-
- To do this simply give the _script_ tag an arbitrary
- _type_ attribute such as _text/x-template_:
-
- script(type='text/template')
- h1 Look!
- p Jade still works in here!
-
-## Interpolation
-
- Both plain-text and piped-text support interpolation,
- which comes in two forms, escapes and non-escaped. The
- following will output the _user.name_ in the paragraph
- but HTML within it will be escaped to prevent XSS attacks:
-
- p Welcome #{user.name}
-
- The following syntax is identical however it will _not_ escape
- HTML, and should only be used with strings that you trust:
-
- p Welcome !{user.name}
-
-## Inline HTML
-
- Sometimes constructing small inline snippets of HTML
- in Jade can be annoying, luckily we can add plain
- HTML as well:
-
- p Welcome <em>#{user.name}</em>
-
-## Code
-
- To buffer output with Jade simply use _=_ at the beginning
- of a line or after a tag. This method escapes any HTML
- present in the string.
-
- p= user.description
-
- To buffer output unescaped use the _!=_ variant, but again
- be careful of XSS.
-
- p!= user.description
-
- The final way to mess with JavaScript code in Jade is the unbuffered
- _-_, which can be used for conditionals, defining variables etc:
-
- - var user = { description: 'foo bar baz' }
- #user
- - if (user.description) {
- h2 Description
- p.description= user.description
- - }
-
- When compiled blocks are wrapped in anonymous functions, so the
- following is also valid, without braces:
-
- - var user = { description: 'foo bar baz' }
- #user
- - if (user.description)
- h2 Description
- p.description= user.description
-
- If you really want you could even use `.forEach()` and others:
-
- - users.forEach(function(user){
- .user
- h2= user.name
- p User #{user.name} is #{user.age} years old
- - })
-
- Taking this further Jade provides some syntax for conditionals,
- iteration, switch statements etc. Let's look at those next!
-
-## Assignment
-
- Jade's first-class assignment is simple, simply use the _=_
- operator and Jade will _var_ it for you. The following are equivalent:
-
- - var user = { name: 'tobi' }
- user = { name: 'tobi' }
-
-## Conditionals
-
- Jade's first-class conditional syntax allows for optional
- parenthesis, and you may now omit the leading _-_ otherwise
- it's identical, still just regular javascript:
-
- user = { description: 'foo bar baz' }
- #user
- if user.description
- h2 Description
- p.description= user.description
-
- Jade provides the negated version, _unless_ as well, the following
- are equivalent:
-
- - if (!(user.isAnonymous))
- p You're logged in as #{user.name}
-
- unless user.isAnonymous
- p You're logged in as #{user.name}
-
-## Iteration
-
- JavaScript's _for_ loops don't look very declarative, so Jade
- also provides its own _for_ loop construct, aliased as _each_:
-
- for user in users
- .user
- h2= user.name
- p user #{user.name} is #{user.age} year old
-
- As mentioned _each_ is identical:
-
- each user in users
- .user
- h2= user.name
-
- If necessary the index is available as well:
-
- for user, i in users
- .user(class='user-#{i}')
- h2= user.name
-
- Remember, it's just JavaScript:
-
- ul#letters
- for letter in ['a', 'b', 'c']
- li= letter
-
-## Mixins
-
- Mixins provide a way to define jade "functions" which "mix in"
- their contents when called. This is useful for abstracting
- out large fragments of Jade.
-
- The simplest possible mixin which accepts no arguments might
- look like this:
-
- mixin hello
- p Hello
-
- You use a mixin by placing `+` before the name:
-
- +hello
-
- For something a little more dynamic, mixins can take
- arguments, the mixin itself is converted to a javascript
- function internally:
-
- mixin hello(user)
- p Hello #{user}
-
- +hello('Tobi')
-
- Yields:
-
- <p>Hello Tobi</p>
-
- Mixins may optionally take blocks, when a block is passed
- its contents becomes the implicit `block` argument. For
- example here is a mixin passed a block, and also invoked
- without passing a block:
-
- mixin article(title)
- .article
- .article-wrapper
- h1= title
- if block
- block
- else
- p No content provided
-
- +article('Hello world')
-
- +article('Hello world')
- p This is my
- p Amazing article
-
- yields:
-
- <div class="article">
- <div class="article-wrapper">
- <h1>Hello world</h1>
- <p>No content provided</p>
- </div>
- </div>
-
- <div class="article">
- <div class="article-wrapper">
- <h1>Hello world</h1>
- <p>This is my</p>
- <p>Amazing article</p>
- </div>
- </div>
-
- Mixins can even take attributes, just like a tag. When
- attributes are passed they become the implicit `attributes`
- argument. Individual attributes can be accessed just like
- normal object properties:
-
- mixin centered
- .centered(class=attributes.class)
- block
-
- +centered.bold Hello world
-
- +centered.red
- p This is my
- p Amazing article
-
- yields:
-
- <div class="centered bold">Hello world</div>
- <div class="centered red">
- <p>This is my</p>
- <p>Amazing article</p>
- </div>
-
- If you use `attributes` directly, *all* passed attributes
- get used:
-
- mixin link
- a.menu(attributes)
- block
-
- +link.highlight(href='#top') Top
- +link#sec1.plain(href='#section1') Section 1
- +link#sec2.plain(href='#section2') Section 2
-
- yields:
-
- <a href="#top" class="highlight menu">Top</a>
- <a id="sec1" href="#section1" class="plain menu">Section 1</a>
- <a id="sec2" href="#section2" class="plain menu">Section 2</a>
-
- If you pass arguments, they must directly follow the mixin:
-
- mixin list(arr)
- if block
- .title
- block
- ul(attributes)
- each item in arr
- li= item
-
- +list(['foo', 'bar', 'baz'])(id='myList', class='bold')
-
- yields:
-
- <ul id="myList" class="bold">
- <li>foo</li>
- <li>bar</li>
- <li>baz</li>
- </ul>
diff --git a/lib/compiler.js b/lib/compiler.js
index 263524f..83e5299 100644
--- a/lib/compiler.js
+++ b/lib/compiler.js
@@ -5,7 +5,7 @@ var filters = require('./filters');
var doctypes = require('./doctypes');
var runtime = require('./runtime');
var utils = require('./utils');
-var selfClosing = require('./self-closing');
+var selfClosing = require('void-elements');
var parseJSExpression = require('character-parser').parseMax;
var constantinople = require('constantinople');
@@ -122,7 +122,7 @@ Compiler.prototype = {
}
}
- str = JSON.stringify(str);
+ str = utils.stringify(str);
str = str.substr(1, str.length - 2);
if (this.lastBufferedIdx == this.buf.length) {
@@ -194,7 +194,7 @@ Compiler.prototype = {
if (debug) {
this.buf.push('jade_debug.unshift({ lineno: ' + node.line
+ ', filename: ' + (node.filename
- ? JSON.stringify(node.filename)
+ ? utils.stringify(node.filename)
: 'jade_debug[0].filename')
+ ' });');
}
@@ -396,8 +396,19 @@ Compiler.prototype = {
if (pp) this.buf.push("jade_indent.pop();")
} else {
var mixin_start = this.buf.length;
- this.buf.push(name + ' = function(' + args + '){');
+ args = args ? args.split(',') : [];
+ var rest;
+ if (args.length && /^\.\.\./.test(args[args.length - 1].trim())) {
+ rest = args.pop().trim().replace(/^\.\.\./, '');
+ }
+ this.buf.push(name + ' = function(' + args.join(',') + '){');
this.buf.push('var block = (this && this.block), attributes = (this && this.attributes) || {};');
+ if (rest) {
+ this.buf.push('var ' + rest + ' = [];');
+ this.buf.push('for (jade_interp = ' + args.length + '; jade_interp < arguments.length; jade_interp++) {');
+ this.buf.push(' ' + rest + '.push(arguments[jade_interp]);');
+ this.buf.push('}');
+ }
this.parentIndents++;
this.visit(block);
this.parentIndents--;
@@ -631,7 +642,7 @@ Compiler.prototype = {
var val = this.attrs(attrs);
attributeBlocks.unshift(val);
}
- this.bufferExpression('jade.attrs(jade.merge([' + attributeBlocks.join(',') + ']), ' + JSON.stringify(this.terse) + ')');
+ this.bufferExpression('jade.attrs(jade.merge([' + attributeBlocks.join(',') + ']), ' + utils.stringify(this.terse) + ')');
} else if (attrs.length) {
this.attrs(attrs, true);
}
@@ -661,11 +672,11 @@ Compiler.prototype = {
if (escaped && !(key.indexOf('data') === 0 && typeof val !== 'string')) {
val = runtime.escape(val);
}
- buf.push(JSON.stringify(key) + ': ' + JSON.stringify(val));
+ buf.push(utils.stringify(key) + ': ' + utils.stringify(val));
}
} else {
if (buffer) {
- this.bufferExpression('jade.attr("' + key + '", ' + attr.val + ', ' + JSON.stringify(escaped) + ', ' + JSON.stringify(this.terse) + ')');
+ this.bufferExpression('jade.attr("' + key + '", ' + attr.val + ', ' + utils.stringify(escaped) + ', ' + utils.stringify(this.terse) + ')');
} else {
var val = attr.val;
if (escaped && !(key.indexOf('data') === 0)) {
@@ -673,7 +684,7 @@ Compiler.prototype = {
} else if (escaped) {
val = '(typeof (jade_interp = ' + val + ') == "string" ? jade.escape(jade_interp) : jade_interp)';
}
- buf.push(JSON.stringify(key) + ': ' + val);
+ buf.push(utils.stringify(key) + ': ' + val);
}
}
}.bind(this));
@@ -681,15 +692,15 @@ Compiler.prototype = {
if (classes.every(isConstant)) {
this.buffer(runtime.cls(classes.map(toConstant), classEscaping));
} else {
- this.bufferExpression('jade.cls([' + classes.join(',') + '], ' + JSON.stringify(classEscaping) + ')');
+ this.bufferExpression('jade.cls([' + classes.join(',') + '], ' + utils.stringify(classEscaping) + ')');
}
} else if (classes.length) {
if (classes.every(isConstant)) {
- classes = JSON.stringify(runtime.joinClasses(classes.map(toConstant).map(runtime.joinClasses).map(function (cls, i) {
+ classes = utils.stringify(runtime.joinClasses(classes.map(toConstant).map(runtime.joinClasses).map(function (cls, i) {
return classEscaping[i] ? runtime.escape(cls) : cls;
})));
} else {
- classes = '(jade_interp = ' + JSON.stringify(classEscaping) + ',' +
+ classes = '(jade_interp = ' + utils.stringify(classEscaping) + ',' +
' jade.joinClasses([' + classes.join(',') + '].map(jade.joinClasses).map(function (cls, i) {' +
' return jade_interp[i] ? jade.escape(cls) : cls' +
' }))' +
diff --git a/lib/filters-client.js b/lib/filters-client.js
index ef1b859..d68e8e2 100644
--- a/lib/filters-client.js
+++ b/lib/filters-client.js
@@ -3,9 +3,8 @@
module.exports = filter;
function filter(name, str, options) {
if (typeof filter[name] === 'function') {
- var res = filter[name](str, options);
+ return filter[name](str, options);
} else {
throw new Error('unknown filter ":' + name + '"');
}
- return res;
}
diff --git a/lib/filters.js b/lib/filters.js
index 47d946e..5a8c468 100644
--- a/lib/filters.js
+++ b/lib/filters.js
@@ -5,11 +5,10 @@ var transformers = require('transformers');
module.exports = filter;
function filter(name, str, options) {
if (typeof filter[name] === 'function') {
- var res = filter[name](str, options);
+ return filter[name](str, options);
} else if (transformers[name]) {
- var res = transformers[name].renderSync(str, options);
+ return transformers[name].renderSync(str, options);
} else {
throw new Error('unknown filter ":' + name + '"');
}
- return res;
}
diff --git a/lib/jade.js b/lib/jade.js
index e43f306..2281679 100644
--- a/lib/jade.js
+++ b/lib/jade.js
@@ -15,13 +15,14 @@ var Parser = require('./parser')
, Compiler = require('./compiler')
, runtime = require('./runtime')
, addWith = require('with')
- , fs = require('fs');
+ , fs = require('fs')
+ , utils = require('./utils');
/**
* Expose self closing tags.
*/
-exports.selfClosing = require('./self-closing');
+exports.selfClosing = require('void-elements');
/**
* Default supported doctypes.
@@ -116,6 +117,10 @@ function parse(str, options){
var globals = [];
+ if (options.globals) {
+ globals = options.globals.slice();
+ }
+
globals.push('jade');
globals.push('jade_mixins');
globals.push('jade_interp');
@@ -152,7 +157,7 @@ function parse(str, options){
exports.compile = function(str, options){
var options = options || {}
, filename = options.filename
- ? JSON.stringify(options.filename)
+ ? utils.stringify(options.filename)
: 'undefined'
, fn;
@@ -165,7 +170,7 @@ exports.compile = function(str, options){
, 'try {'
, parsed.body
, '} catch (err) {'
- , ' jade.rethrow(err, jade_debug[0].filename, jade_debug[0].lineno' + (options.compileDebug === true ? ',' + JSON.stringify(str) : '') + ');'
+ , ' jade.rethrow(err, jade_debug[0].filename, jade_debug[0].lineno' + (options.compileDebug === true ? ',' + utils.stringify(str) : '') + ');'
, '}'
].join('\n');
} else {
@@ -204,7 +209,7 @@ exports.compile = function(str, options){
exports.compileClient = function(str, options){
var options = options || {};
var name = options.name || 'template';
- var filename = options.filename ? JSON.stringify(options.filename) : 'undefined';
+ var filename = options.filename ? utils.stringify(options.filename) : 'undefined';
var fn;
str = String(str);
@@ -216,7 +221,7 @@ exports.compileClient = function(str, options){
, 'try {'
, parse(str, options).body
, '} catch (err) {'
- , ' jade.rethrow(err, jade_debug[0].filename, jade_debug[0].lineno, ' + JSON.stringify(str) + ');'
+ , ' jade.rethrow(err, jade_debug[0].filename, jade_debug[0].lineno, ' + utils.stringify(str) + ');'
, '}'
].join('\n');
} else {
diff --git a/lib/lexer.js b/lib/lexer.js
index 1ec04c9..f4b3551 100644
--- a/lib/lexer.js
+++ b/lib/lexer.js
@@ -369,8 +369,8 @@ Lexer.prototype = {
mixinBlock: function() {
var captures;
- if (captures = /^block\s*(\n|$)/.exec(this.input)) {
- this.consume(captures[0].length - 1);
+ if (captures = /^block[ \t]*(\n|$)/.exec(this.input)) {
+ this.consume(captures[0].length - captures[1].length);
return this.tok('mixin-block');
}
},
@@ -402,7 +402,7 @@ Lexer.prototype = {
var filter = captures[1];
var attrs = captures[2] === '(' ? this.attrs() : null;
if (!(captures[2] === ' ' || this.input[0] === ' ')) {
- throw new Error('expected space after include:filter but got ' + JSON.stringify(this.input[0]));
+ throw new Error('expected space after include:filter but got ' + utils.stringify(this.input[0]));
}
captures = /^ *([^\n]+)/.exec(this.input);
if (!captures || captures[1].trim() === '') {
@@ -448,17 +448,17 @@ Lexer.prototype = {
call: function(){
var tok, captures;
- if (captures = /^\+(([-\w]+)|(#\{))/.exec(this.input)) {
+ if (captures = /^\+(\s*)(([-\w]+)|(#\{))/.exec(this.input)) {
// try to consume simple or interpolated call
- if (captures[2]) {
+ if (captures[3]) {
// simple call
this.consume(captures[0].length);
- tok = this.tok('call', captures[2]);
+ tok = this.tok('call', captures[3]);
} else {
// interpolated call
var match;
try {
- match = this.bracketExpression(2);
+ match = this.bracketExpression(2 + captures[1].length);
} catch (ex) {
return;//not an interpolation expression, just an unmatched open interpolation
}
diff --git a/lib/parser.js b/lib/parser.js
index 93c7836..b479f83 100644
--- a/lib/parser.js
+++ b/lib/parser.js
@@ -489,6 +489,7 @@ Parser.prototype = {
parser.dependencies = this.dependencies;
parser.blocks = this.blocks;
+ parser.included = this.included;
parser.contexts = this.contexts;
this.extending = parser;
diff --git a/lib/self-closing.js b/lib/self-closing.js
deleted file mode 100644
index 3ab7de9..0000000
--- a/lib/self-closing.js
+++ /dev/null
@@ -1,22 +0,0 @@
-'use strict';
-
-// source: http://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
-
-module.exports = [
- 'area'
- , 'base'
- , 'br'
- , 'col'
- , 'embed'
- , 'hr'
- , 'img'
- , 'input'
- , 'keygen'
- , 'link'
- , 'menuitem'
- , 'meta'
- , 'param'
- , 'source'
- , 'track'
- , 'wbr'
-];
diff --git a/lib/utils.js b/lib/utils.js
index 813a55a..ad5f016 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -14,6 +14,12 @@ exports.merge = function(a, b) {
return a;
};
+exports.stringify = function(str) {
+ return JSON.stringify(str)
+ .replace(/\u2028/g, '\\u2028')
+ .replace(/\u2029/g, '\\u2029');
+};
+
exports.walkAST = function walkAST(ast, before, after) {
before && before(ast);
switch (ast.type) {
diff --git a/package.json b/package.json
index 16511af..9a72d0e 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "jade",
"description": "Jade template engine",
- "version": "1.5.0",
+ "version": "1.7.0",
"author": "TJ Holowaychuk <tj at vision-media.ca>",
"maintainers": [
"forbeslindesay <forbes at lindesay.co.uk>",
@@ -18,13 +18,14 @@
"jade": "./bin/jade.js"
},
"dependencies": {
+ "character-parser": "1.2.0",
"commander": "2.1.0",
+ "constantinople": "~2.0.0",
"mkdirp": "~0.5.0",
- "transformers": "2.1.0",
- "character-parser": "1.2.0",
"monocle": "1.1.51",
- "with": "~3.0.0",
- "constantinople": "~2.0.0"
+ "transformers": "2.1.0",
+ "void-elements": "~1.0.0",
+ "with": "~3.0.0"
},
"devDependencies": {
"coffee-script": "*",
diff --git a/test/cases/auxiliary/mixin-at-end-of-file.jade b/test/cases/auxiliary/mixin-at-end-of-file.jade
new file mode 100644
index 0000000..e51eb01
--- /dev/null
+++ b/test/cases/auxiliary/mixin-at-end-of-file.jade
@@ -0,0 +1,3 @@
+mixin slide
+ section.slide
+ block
\ No newline at end of file
diff --git a/test/cases/mixin-at-end-of-file.html b/test/cases/mixin-at-end-of-file.html
new file mode 100644
index 0000000..495ca32
--- /dev/null
+++ b/test/cases/mixin-at-end-of-file.html
@@ -0,0 +1,3 @@
+<section class="slide">
+ <p>some awesome content</p>
+</section>
diff --git a/test/cases/mixin-at-end-of-file.jade b/test/cases/mixin-at-end-of-file.jade
new file mode 100644
index 0000000..c78c442
--- /dev/null
+++ b/test/cases/mixin-at-end-of-file.jade
@@ -0,0 +1,4 @@
+include ./auxiliary/mixin-at-end-of-file.jade
+
++slide()
+ p some awesome content
diff --git a/test/cases/mixin.attrs.html b/test/cases/mixin.attrs.html
index a767cf5..4857752 100644
--- a/test/cases/mixin.attrs.html
+++ b/test/cases/mixin.attrs.html
@@ -24,4 +24,5 @@
</div>
</body>
<div attr1="foo" attr2="bar" class="thing foo bar thunk" attr3="baz" data-foo="<biz>" data-bar="<biz>"></div>
-<div data-profile="profile" data-creator-name="name">work</div>
\ No newline at end of file
+<div data-profile="profile" data-creator-name="name">work</div>
+<div attr1="foo" attr2="bar" class="thing baz" attr3="qux"></div>
diff --git a/test/cases/mixin.attrs.jade b/test/cases/mixin.attrs.jade
index 804d58b..f2e1dc9 100644
--- a/test/cases/mixin.attrs.jade
+++ b/test/cases/mixin.attrs.jade
@@ -39,3 +39,8 @@ mixin foo
mixin work_filmstrip_item(work)
div&attributes(attributes)= work
+work_filmstrip_item('work')("data-profile"='profile', "data-creator-name"='name')
+
++foo(
+ attr3="qux"
+ class="baz"
+)
diff --git a/test/cases/mixins.html b/test/cases/mixins.html
index fbf6df0..51668be 100644
--- a/test/cases/mixins.html
+++ b/test/cases/mixins.html
@@ -13,5 +13,15 @@
<li>bar</li>
<li>baz</li>
</ul>
+ <ul>
+ <li>foo</li>
+ <li>bar</li>
+ <li>baz</li>
+ </ul>
+ <ul>
+ <li>foo</li>
+ <li>bar</li>
+ <li>baz</li>
+ </ul>
</body>
<div id="interpolation">This is interpolated</div>
diff --git a/test/cases/mixins.jade b/test/cases/mixins.jade
index 0ee7106..0d79eb5 100644
--- a/test/cases/mixins.jade
+++ b/test/cases/mixins.jade
@@ -23,6 +23,8 @@ mixin list
body
mixin list()
+ +list()
+ + list()
mixin foobar(str)
div#interpolation= str + 'interpolated'
diff --git a/test/cases/mixins.rest-args.html b/test/cases/mixins.rest-args.html
new file mode 100644
index 0000000..5b37365
--- /dev/null
+++ b/test/cases/mixins.rest-args.html
@@ -0,0 +1,6 @@
+<ul>
+ <li>1</li>
+ <li>2</li>
+ <li>3</li>
+ <li>4</li>
+</ul>
diff --git a/test/cases/mixins.rest-args.jade b/test/cases/mixins.rest-args.jade
new file mode 100644
index 0000000..929a927
--- /dev/null
+++ b/test/cases/mixins.rest-args.jade
@@ -0,0 +1,6 @@
+mixin list(tag, ...items)
+ #{tag}
+ each item in items
+ li= item
+
++list('ul', 1, 2, 3, 4)
diff --git a/test/error.reporting.js b/test/error.reporting.js
index 2048e1b..fc21837 100644
--- a/test/error.reporting.js
+++ b/test/error.reporting.js
@@ -99,6 +99,14 @@ describe('error reporting', function () {
assert(err.message.indexOf('missing path for include:filter') !== -1);
});
});
+ describe('mixin block followed by a lot of blank lines', function () {
+ it('reports the correct line number', function () {
+ var err = getError('mixin test\n block\n\ndiv()Test');
+ var line = /Jade\:(\d+)/.exec(err.message);
+ assert(line, 'Line number must be included in error message');
+ assert(line[1] === '4', 'The error should be reported on line 4, not line ' + line[1]);
+ });
+ });
});
describe('runtime errors', function () {
describe('with no filename and `compileDebug` left undefined', function () {
diff --git a/test/fixtures/issue-1593/include-layout.jade b/test/fixtures/issue-1593/include-layout.jade
new file mode 100644
index 0000000..224225f
--- /dev/null
+++ b/test/fixtures/issue-1593/include-layout.jade
@@ -0,0 +1,2 @@
+.included-layout
+ block include-body
diff --git a/test/fixtures/issue-1593/include.jade b/test/fixtures/issue-1593/include.jade
new file mode 100644
index 0000000..4f53eee
--- /dev/null
+++ b/test/fixtures/issue-1593/include.jade
@@ -0,0 +1,4 @@
+extends ./include-layout.jade
+
+block include-body
+ .include-body
diff --git a/test/fixtures/issue-1593/index.jade b/test/fixtures/issue-1593/index.jade
new file mode 100644
index 0000000..03099e5
--- /dev/null
+++ b/test/fixtures/issue-1593/index.jade
@@ -0,0 +1,7 @@
+extends ./layout.jade
+
+block body-a
+ .body-a
+block body-b
+ .body-b
+ include ./include.jade
diff --git a/test/fixtures/issue-1593/layout.jade b/test/fixtures/issue-1593/layout.jade
new file mode 100644
index 0000000..a235db7
--- /dev/null
+++ b/test/fixtures/issue-1593/layout.jade
@@ -0,0 +1,3 @@
+.layout-body
+ block body-a
+ block body-b
diff --git a/test/jade.test.js b/test/jade.test.js
index 218b26b..a7016ad 100644
--- a/test/jade.test.js
+++ b/test/jade.test.js
@@ -868,6 +868,10 @@ describe('jade', function(){
assert.equal('<html><head><script src=\"/jquery.js\"></script><script src=\"/caustic.js\"></script><scripts src=\"/app.js\"></scripts></head></html>'
, jade.render(str, { filename: __dirname + '/jade.test.js' }));
});
+
+ it('does not produce warnings for issue-1593', function () {
+ jade.compileFile(__dirname + '/fixtures/issue-1593/index.jade');
+ });
});
describe('.render()', function(){
@@ -1054,5 +1058,9 @@ describe('jade', function(){
path.resolve(__dirname + '/dependencies/dependency3.jade')
],info.dependencies);
});
+ it('should not fail on js newlines', function(){
+ assert.equal("<p>foo\u2028bar</p>", jade.render("p foo\u2028bar"));
+ assert.equal("<p>foo\u2029bar</p>", jade.render("p foo\u2029bar"));
+ });
});
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-jade.git
More information about the Pkg-javascript-commits
mailing list