pax_global_header00006660000000000000000000000064123700214370014511gustar00rootroot0000000000000052 comment=e8070eb8827236d58b2f412d9173543c01ec6820 node-jade-1.5.0+dfsg/000077500000000000000000000000001237002143700142615ustar00rootroot00000000000000node-jade-1.5.0+dfsg/.gitignore000066400000000000000000000001741237002143700162530ustar00rootroot00000000000000.DS_Store .idea lib-cov testing node_modules lib-cov coverage npm-debug.log /test/output /test/temp /docs/out .release.json node-jade-1.5.0+dfsg/.gitmodules000066400000000000000000000013231237002143700164350ustar00rootroot00000000000000[submodule "support/expresso"] path = support/expresso url = git://github.com/visionmedia/expresso.git [submodule "support/sass"] path = support/sass url = git://github.com/visionmedia/sass.js.git [submodule "benchmarks/haml-js"] path = benchmarks/haml-js url = git://github.com/creationix/haml-js.git [submodule "benchmarks/ejs"] path = benchmarks/ejs url = git://github.com/visionmedia/ejs.git [submodule "benchmarks/haml"] path = benchmarks/haml url = git://github.com/visionmedia/haml.js.git [submodule "support/coffee-script"] path = support/coffee-script url = http://github.com/jashkenas/coffee-script.git [submodule "support/stylus"] path = support/stylus url = git://github.com/LearnBoost/stylus.git node-jade-1.5.0+dfsg/.npmignore000066400000000000000000000002111237002143700162520ustar00rootroot00000000000000test support benchmarks examples lib-cov coverage .gitmodules .travis.yml History.md Makefile test/ support/ benchmarks/ examples/ docs/ node-jade-1.5.0+dfsg/.travis.yml000066400000000000000000000000461237002143700163720ustar00rootroot00000000000000language: node_js node_js: - "0.10" node-jade-1.5.0+dfsg/History.md000066400000000000000000000742721237002143700162600ustar00rootroot000000000000001.5.0 / 2014-07-23 ================== * Added compileFile API ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Fix line number in un-used blocks warning ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Fix a warning that eroniously warned for un-used blocks if they were under another block (Reported by [@pesho](https://github.com/pesho)) 1.4.2 / 2014-07-16 ================== * Fix a warning that eroniously warned for un-used blocks if they were under a "Code" element (Reported by [@narirou](https://github.com/narirou)) 1.4.1 / 2014-07-16 ================== * Fix an error that sometimes resulted in 'unexpected token "pipless-text"' being erroniously thrown (Reported by [@Artazor](https://github.com/Artazor) and [@thenitai](https://github.com/thenitai)) 1.4.0 / 2014-07-15 ================== * Fix CLI so it keeps watching when errors occur ([@AndrewTsao](https://github.com/AndrewTsao)) * Support custom names for client side templates ([@ForbesLindesay](http://www.forbeslindesay.co.uk/) and [@dscape](https://github.com/dscape)) * Allow whitepsace other than "space" before attributes passed to mixins (N.B. there is a small chance this could be a breaking change for you) ([@regular](https://github.com/regular)) * Track dependencies so file watchers can be more clever ([@ForbesLindesay](http://www.forbeslindesay.co.uk/) and [@sdether](https://github.com/sdether)) * Allow passing options to filtered includes ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Fix bugs with indentation in filters ([@ForbesLindesay](http://www.forbeslindesay.co.uk/) and [@lackac](https://github.com/lackac)) * Warn on block names that are never used ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) 1.3.1 / 2014-04-04 ================== * Fix error with tags in xml that are self-closing in html ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Fix error message for inline tags with content ([@hiddentao](https://github.com/hiddentao)) 1.3.0 / 2014-03-02 ================== * Fix a bug where sometimes mixins were removed by an optimisation even though they were being called ([@ForbesLindesay](http://www.forbeslindesay.co.uk/), reported by [@leider](https://github.com/leider)) * Updated with to support automatically detecting when a value is "global" and removed redundant `options.globals` option ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Improve warnings for tags with multiple attributes ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Deprecate (with a warning) `node.clone`, `block.replace`, `attrs.removeAttribute`, `attrs.getAttribute` - these are all internal APIs for the AST ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) 1.2.0 / 2014-02-26 ================== * Use variables instead of properties of jade, improving performance and reliability with nested templates ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Support compiling templates from stdin via a user typing ([@yorkie](https://github.com/yorkie)) * Lazily add mixins ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Fix case fall-through ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Earlier errors for `when` without `case` and `else` without `if` ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Allow `if`/`else` etc. to not have a block. * Remove lib-cov legacy to make browserify work better ([@silver83](https://github.com/silver83)) * Add and improve test coverage using istanbul ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) 1.1.5 / 2014-01-19 ================== * Add filename to and fix line numbers for missing space before text warning (@ijin82) * Fix filenames for some error reporting in extends/includes (@doublerebel) * Fix a corner case where a mixin was called with `&attributes` but no other attributes and a block that was supposed to be fixed in 1.1.4 ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) 1.1.4 / 2014-01-09 ================== * Fix a corner case where a mixin was called with `&attributes` but no other attributes and a block ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) 1.1.3 / 2014-01-09 ================== * Fix failure of npm prepublish not running 1.1.2 / 2014-01-09 ================== * Fix same interaction of `&attributes` with `false` `null` or `undefined` but combined with dynamic attributes ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) 1.1.1 / 2014-01-09 ================== * Fix a bug when `&attributes` is combined with static attributes that evaluate to `false` or `null` or `undefined` ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) 1.1.0 / 2014-01-07 ================== * Fix class merging to work as documented ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Throw an error when the same attribute is duplicated multiple times ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Move more errors into the parser/lexer so they have more info about line numbers ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Support mixin blocks at the end of files ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) 1.0.2 / 2013-12-31 ================== * Fix a bug when `&attributes` is combined with dynamic attributes ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) 1.0.1 / 2013-12-29 ================== * Allow self closing tags to contian whitespace ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Allow tags to have a single white space after them ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Support text bodies of tags that begin with `//` rather than treating them as comments ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) 1.0.0 / 2013-12-22 ================== * No longer support node@0.8 ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Fix error reporting in layouts & includes ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Allow a list of 'globals' to be passed as an array at compile time & don't automatically expose all globals ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Escape apostrophes in data attributes (@qualiabyte) * Fix mixin/block interaction ([@ForbesLindesay](http://www.forbeslindesay.co.uk/) & [@paulyoung](https://github.com/paulyoung)) * Ignore trailing space after mixin declaration ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Make literal `.` work as expected ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Remove implicit text only for script/style ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Stop parsing comments and remove support for conditional comments ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Make filtering includes explicit ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Remove special assignment syntax ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Remove `!!!` shortcut for `doctype` ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Remove `5` shorcut for `html` doctype ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Remove `colons` option from the distant past ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Add a sepatate `compileClient` and `compileFileClient` to replace the `client` option ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Remove polyfills for supporting old browsers ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Allow interpolation for mixin names ([@jeromew](https://github.com/jeromew) * Use `node.type` instead of `node.constructor.name` so it can be minified ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Allow hyphens in filter names ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Throw an error if a self closing tag has content ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Support inline tags ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Replace `attributes` magic attribute with `&attributes(attributes)` ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Remove automatic tag wrapping for filters, you can just put the tags in yourself now ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Remove whitespace from tags nested inside pre tags ([@markdalgleish](http://markdalgleish.com)) 0.35.0 / 2013-08-21 =================== * Add support for space separated attributes (thanks to [@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Add earlier errors for invalid JavaScript expressions (thanks to [@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * Fix parsing files with UTF8 BOMs when they are includes or parent/layout templates (thanks to [@kiinoo](https://github.com/kiinoo)) 0.34.1 / 2013-07-26 =================== * fix render file not working when called with callback (reported by [@xieren58](https://github.com/xieren58)) 0.34.0 / 2013-07-26 =================== * callbacks only called once for async methods even if they throw (reported by [@davidcornu](https://github.com/davidcornu)) * HTML comments are pretty printed better (thanks to [@eddiemonge](https://github.com/eddiemonge)) * callbacks are optional and leaving them out results in synchronous operation (thanks to [@ForbesLindesay](http://www.forbeslindesay.co.uk/)) * empty filter nodes are now permitted (thanks to [@coderanger](https://github.com/coderanger)) * overhaul website and documentation (thanks to [@ForbesLindesay](http://www.forbeslindesay.co.uk/)), much more of this to come. 0.33.0 / 2013-07-12 =================== * Hugely more powerful error reporting (especially with `compileDebug` set explicitly to `true`) * Add a warning for tags with multiple attributes * be strict about requiring newlines after tags to fix some odd corner cases * fix escaping of class to allow it to be unescaped (thanks to [@christiangenco](https://github.com/christiangenco)) 0.32.0 / 2013-06-28 =================== * remove `jade.version` and fix `jade --version` * add file name and line number to deprecation warnings * use constantinople for better constant detection * update `with` for a massive performance upgrade at compile time 0.31.2 / 2013-06-07 =================== * fix overzealous deprecation warnings 0.31.1 / 2013-05-31 =================== * fix line endings for executable command * fix `locals` variable being undefined * fix an obscure bug that could occur if multiple mixins interact badly (see [substack/lexical-scope#13](https://github.com/substack/lexical-scope/issues/13)) 0.31.0 / 2013-05-30 ================== * deprecate implicit text-only `script` and `style` tags * make `with` at compile time using `lexical-scope` * add `options.parser` that behaves exactly like `options.compiler` * add "component.json" for component (runtime) support * removed `hasOwnProperty` check in each loops * removed .min files from the repository (people can just generate these themselves) * use browserify to compile client side libraries * fix buggy block extending should now be fixed * fix preserve case of custom doctypes * fix regexps in attributes sometimes not being accepted * fix allow `$` sign in each loop variable names * fix mixins with buffered code on the same line * fix separate class names by ` ` rather than `,` (was sometimes incorrect) 0.30.0 / 2013-04-25 ================== * add support for 'include' and 'extends' to use paths relative to basedir * fix accidental calling of functions in iteration block. Closes #986 * fix: skip rethrow on client * fix each/else prefixed with `-` * fix multi-block prepend/append * swap -o and -O, set -o to --out 0.29.0 / 2013-04-16 ================== * add "monocle" for watcher that actually works... * fix interpolation in blocks of text * fix attribute interpolation * move filters to an external library * fix JavaScript escaping corner cases 0.28.2 / 2013-03-04 ================== * wtf coffeescript is not a dep 0.28.1 / 2013-01-10 ================== * add passing of filename to include filters * fix wrong new lines for include filters 0.28.0 / 2013-01-08 ================== * add .css and .js "filters". re #438 * add include filters. Closes #283 * fix "class:" within attribute escaping * removing ast filters * things I can't read: * 反馈地址 * 样式 * 联系 * 初稿,翻译完 * 接受大鸟的建议 * 头晕,翻译一点点 * 到过滤器翻译完毕 * 翻译一部分 * 中文翻译单独放 * 特性部分 * 再翻 * 翻译一点点 0.27.7 / 2012-11-05 ================== * fix each/else clause for enumerated objects * fix #764 (incorrect line number for error messages) * fix double-escaping of interpolated js slashes. Closes #784 0.27.6 / 2012-10-05 ================== * Included templates can not override blocks of their parent. Closes #699 0.27.5 / 2012-09-24 ================== * fix attr interpolation escaping. Closes #771 0.27.4 / 2012-09-18 ================== * fix include yields. Closes #770 0.27.3 / 2012-09-18 ================== * fix escaping of interpolation. Closes #769 * loosen "mkdirp" version restriction [TooTallNate] 0.27.2 / 2012-08-07 ================== * Revert "fixing string interpolation escaping #731", problems reported 0.27.1 / 2012-08-06 ================== * fix attribute interpolation escaping #731 * fix string interpolation escaping #731 0.27.0 / 2012-07-26 ================== * added ability to pass in json file to `--obj` * add preliminary `each` `else` support. Closes #716 * fix doctype bug overlooked in #712 * fix stripping of utf-8 BOMs 0.26.3 / 2012-06-25 ================== * Update version of commander that supports node v0.8. 0.26.2 / 2012-06-22 ================== * Added --options alias of --obj * Added reserved word conflict prevention in Google's Closure Compiler * Added tag interpolation. Closes #657 * Allow the compiled client to use it's own jade util functions [3rd-Eden] * Fixed `attrs()` escape bug [caseywebdev] 0.26.1 / 2012-05-27 ================== * Changed default doctype to __html5__ * Performance: statically compile attrs when possible [chowey] * Fixed some class attribute merging cases * Fixed so `block` doesn't consume `blockquotes` tag [chowey] * Fixed backslashes in text nodes [chowey] * Fixed / in text. Closes #638 0.26.0 / 2012-05-04 ================== * Added package.json __component__ support * Added explicit self-closing tag support. Closes #605 * Added `block` statement * Added mixin tag-like behaviour [chowey] * Fixed mixins with extends [chowey] 0.25.0 / 2012-04-18 ================== * Added preliminary mixin block support. Closes #310 * Fixed whitespace handling in various situations [chowey] * Fixed indentation in various situations [chowey] 0.24.0 / 2012-04-12 ================== * Fixed unescaped attribute compilation * Fixed pretty-printing of text-only tags (__Warning__: this may affect rendering) [chowey] 0.23.0 / 2012-04-11 ================== * Added data-attr json stringification support. Closes #572 * Added unescaped attr support. Closes #198 * Fixed #1070, reverted mixin function statements * Fixed jade.1 typo 0.22.1 / 2012-04-04 ================== * Fixed source tags. now self-closing. Closes #308 * Fixed: escape backslashes in coffeescript filter 0.22.0 / 2012-03-22 ================== * Added jade manpage (`man jade` after installation for docs) * Added `-D, --no-debug` to jade(1) * Added `-p, --pretty` to jade(1) * Added `-c, --client` option to jade(1) * Fixed `-o { client: true }` with stdin * Fixed: skip blank lines in lexer (unless within pipeless text). Closes #399 0.21.0 / 2012-03-10 ================== * Added new input/output test suite using Mocha's string diffing * Added alias `extend` -> `extends`. Closes #527 [guillermo] * Fixed include escapes. Closes #513 * Fixed block-expansion with .foo and #foo short-hands. Closes #498 0.20.3 / 2012-02-16 ================== * Changed: pass `.filename` to filters only 0.20.2 / 2012-02-16 ================== * Fixed `:stylus` import capabilities, pass .filename 0.20.1 / 2012-02-02 ================== * Fixed Block#includeBlock() with textOnly blocks 0.20.0 / 2011-12-28 ================== * Added a browser example * Added `yield` for block `include`s * Changed: replaced internal `__` var with `__jade` [chrisleishman] * Fixed two globals. Closes #433 0.19.0 / 2011-12-02 ================== * Added block `append` / `prepend` support. Closes #355 * Added link in readme to jade-mode for Emacs * Added link to python implementation 0.18.0 / 2011-11-21 ================== * Changed: only ['script', 'style'] are text-only. Closes #398' 0.17.0 / 2011-11-10 ================== * jade.renderFile() is back! (for express 3.x) * Fixed `Object.keys()` failover bug 0.16.4 / 2011-10-24 ================== * Fixed a test due to reserved keyword * Fixed: commander 0.1.x dep for 0.5.x 0.16.3 / 2011-10-24 ================== * Added: allow leading space for conditional comments * Added quick implementation of a switch statement * Fixed parens in mixin args. Closes #380 * Fixed: include files with a .jade extension as jade files 0.16.2 / 2011-09-30 ================== * Fixed include regression. Closes #354 0.16.1 / 2011-09-29 ================== * Fixed unexpected `else` bug when compileDebug: false * Fixed attr state issue for balancing pairs. Closes #353 0.16.0 / 2011-09-26 ================== * Added `include` block support. Closes #303 * Added template inheritance via `block` and `extends`. Closes #242 * Added 'type="text/css"' to the style tags generated by filters. * Added 'uglifyjs' as an explicit devDependency. * Added -p, --path flag to jade(1) * Added support for any arbitrary doctype * Added `jade.render(str[,options], fn)` back * Added first-class `while` support * Added first-class assignment support * Fixed runtime.js `Array.isArray()` polyfill. Closes #345 * Fixed: set .filename option in jade(1) when passing filenames * Fixed `Object.keys()` polyfill typo. Closes #331 * Fixed `include` error context * Renamed magic "index" to "$index". Closes #350 0.15.4 / 2011-09-05 ================== * Fixed script template html. Closes #316 * Revert "Fixed script() tag with trailing ".". Closes #314" 0.15.3 / 2011-08-30 ================== * Added Makefile example. Closes #312 * Fixed script() tag with trailing ".". Closes #314 0.15.2 / 2011-08-26 ================== * Fixed new conditional boundaries. Closes #307 0.15.1 / 2011-08-26 ================== * Fixed jade(1) support due to `res.render()` removal * Removed --watch support (use a makefile + watch...) 0.15.0 / 2011-08-26 ================== * Added `client` option to reference runtime helpers * Added `Array.isArray()` for runtime.js as well * Added `Object.keys()` for the client-side runtime * Added first-class `if`, `unless`, `else` and `else if` support * Added first-class `each` / `for` support * Added `make benchmark` for continuous-bench * Removed `inline` option, SS helpers are no longer inlined either * Removed `Parser#debug()` * Removed `jade.render()` and `jade.renderFile()` * Fixed runtime.js `escape()` bug causing window.escape to be used * Fixed a bunch of tests 0.14.2 / 2011-08-16 ================== * Added `include` support for non-jade files * Fixed code indentation when followed by newline(s). Closes #295 [reported by masylum] 0.14.1 / 2011-08-14 ================== * Added `colons` option for everyone stuck with ":". Closes #231 * Optimization: consecutive lines are merged in compiled js 0.14.0 / 2011-08-08 ================== * Added array iteration with index example. Closes #276 * Added _runtime.js_ * Added `compileDebug` option to enable lineno instrumentation * Added `inline` option to disable inlining of helpers (for client-side) 0.13.0 / 2011-07-13 ================== * Added `mixin` support * Added `include` support * Added array support for the class attribute 0.12.4 / 2011-06-23 ================== * Fixed filter indentation bug. Closes #243 0.12.3 / 2011-06-21 ================== * Fixed empty strings support. Closes #223 * Fixed conditional comments documentation. Closes #245 0.12.2 / 2011-06-16 ================== * Fixed `make test` * Fixed block comments 0.12.1 / 2011-06-04 ================== * Fixed attribute interpolation with double quotes. Fixes #232 [topaxi] 0.12.0 / 2011-06-03 ================== * Added `doctype` as alias of `!!!` * Added; doctype value is now case-insensitive * Added attribute interpolation support * Fixed; retain original indentation spaces in text blocks 0.11.1 / 2011-06-01 ================== * Fixed text block indentation [Laszlo Bacsi] * Changed; utilizing devDependencies * Fixed try/catch issue with renderFile(). Closes #227 * Removed attribute ":" support, use "=" (option for ':' coming soon) 0.11.0 / 2011-05-14 ================== * Added `self` object to avoid poor `with(){}` performance [masylum] * Added `doctype` option [Jeremy Larkin] 0.10.7 / 2011-05-04 ================== * expose Parser 0.10.6 / 2011-04-29 ================== * Fixed CS `Object.keys()` [reported by robholland] 0.10.5 / 2011-04-26 ================== * Added error context after the lineno * Added; indicate failing lineno with ">" * Added `Object.keys()` for the client-side * Fixed attr strings when containing the opposite quote. Closes 207 * Fixed attr issue with js expressions within strings * Fixed single-quote filter escape bug. Closes #196 0.10.4 / 2011-04-05 ================== * Added `html` doctype, same as "5" * Fixed `pre`, no longer text-only 0.10.3 / 2011-03-30 ================== * Fixed support for quoted attribute keys ex `rss("xmlns:atom"="atom")` 0.10.2 / 2011-03-30 ================== * Fixed pipeless text bug with missing outdent 0.10.1 / 2011-03-28 ================== * Fixed `support/compile.js` to exclude browser js in node * Fixes for IE [Patrick Pfeiffer] 0.10.0 / 2011-03-25 ================== * Added AST-filter support back in the form of `[attrs]<:>` 0.9.3 / 2011-03-24 ================== * Added `Block#unshift(node)` * Added `jade.js` for the client-side to the repo * Added `jade.min.js` for the client-side to the repo * Removed need for pipes in filters. Closes #185 Note that this _will_ break filters used to manipulate the AST, until we have a different syntax for doing so. 0.9.2 / 2011-03-23 ================== * Added jade `--version` * Removed `${}` interpolation support, use `#{}` 0.9.1 / 2011-03-16 ================== * Fixed invalid `.map()` call due to recent changes 0.9.0 / 2011-03-16 ================== * Added client-side browser support via `make jade.js` and `make jade.min.js`. 0.8.9 / 2011-03-15 ================== * Fixed preservation of newlines in text blocks 0.8.8 / 2011-03-14 ================== * Fixed jade(1) stdio 0.8.7 / 2011-03-14 ================== * Added `mkdirs()` to jade(1) * Added jade(1) stdio support * Added new features to jade(1), `--watch`, recursive compilation etc [khingebjerg] * Fixed pipe-less text newlines * Removed jade(1) `--pipe` flag 0.8.6 / 2011-03-11 ================== * Fixed parenthesized expressions in attrs. Closes #170 * Changed; default interpolation values `== null` to ''. Closes #167 0.8.5 / 2011-03-09 ================== * Added pipe-less text support with immediate ".". Closes #157 * Fixed object support in attrs * Fixed array support for attrs 0.8.4 / 2011-03-08 ================== * Fixed issue with expressions being evaluated several times. closes #162 0.8.2 / 2011-03-07 ================== * Added markdown, discount, and markdown-js support to `:markdown`. Closes #160 * Removed `:discount` 0.8.1 / 2011-03-04 ================== * Added `pre` pipe-less text support (and auto-escaping) 0.8.0 / 2011-03-04 ================== * Added block-expansion support. Closes #74 * Added support for multi-line attrs without commas. Closes #65 0.7.1 / 2011-03-04 ================== * Fixed `script()` etc pipe-less text with attrs 0.7.0 / 2011-03-04 ================== * Removed `:javascript` filter (it doesn't really do anything special, use `script` tags) * Added pipe-less text support. Tags that only accept text nodes (`script`, `textarea`, etc) do not require `|`. * Added `:text` filter for ad-hoc pipe-less * Added flexible indentation. Tabs, arbitrary number of spaces etc * Added conditional-comment support. Closes #146 * Added block comment support * Added rss example * Added `:stylus` filter * Added `:discount` filter * Fixed; auto-detect xml and do not self-close tags. Closes #147 * Fixed whitespace issue. Closes #118 * Fixed attrs. `,`, `=`, and `:` within attr value strings are valid Closes #133 * Fixed; only output "" when code == null. Ex: `span.name= user.name` when undefined or null will not output "undefined". Closes #130 * Fixed; throw on unexpected token instead of hanging 0.6.3 / 2011-02-02 ================== * Added `each` support for Array-like objects [guillermo] 0.6.2 / 2011-02-02 ================== * Added CSRF example, showing how you can transparently add inputs to a form * Added link to vim-jade * Fixed self-closing col support [guillermo] * Fixed exception when getAttribute or removeAttribute run into removed attributes [Naitik Shah] 0.6.0 / 2010-12-19 ================== * Added unescaped interpolation variant `!{code}`. Closes #124 * Changed; escape interpolated code by default `#{code}` 0.5.7 / 2010-12-08 ================== * Fixed; hyphen in get `tag()` 0.5.6 / 2010-11-24 ================== * Added `exports.compile(str, options)` * Renamed internal `_` to `__`, since `_()` is commonly used for translation 0.5.5 / 2010-10-30 ================== * Add _coffeescript_ filter [Michael Hampton] * Added link to _slim_; a ruby implementation * Fixed quoted attributes issue. * Fixed attribute issue with over greedy regexp. Previously "p(foo=(((('bar')))))= ((('baz')))" would __fail__ for example since the regexp would lookahead to far. Now we simply pair the delimiters. 0.5.4 / 2010-10-18 ================== * Adding newline when using tag code when preceding text * Assume newline in tag text when preceding text * Changed; retain leading text whitespace * Fixed code block support to prevent multiple buffer openings [Jake Luer] * Fixed nested filter support 0.5.3 / 2010-10-06 ================== * Fixed bug when tags with code also have a block [reported by chrisirhc] 0.5.2 / 2010-10-05 ================== * Added; Text introduces newlines to mimic the grammar. Whitespace handling is a little tricky with this sort of grammar. Jade will now mimic the written grammar, meaning that text blocks using the "|" margin character will introduce a literal newline, where as immediate tag text (ex "a(href='#') Link") will not. This may not be ideal, but it makes more sense than what Jade was previously doing. * Added `Tag#text` to disambiguate between immediate / block text * Removed _pretty_ option (was kinda useless in the state it was in) * Reverted ignoring of newlines. Closes #92. * Fixed; `Parser#parse()` ignoring newlines 0.5.1 / 2010-10-04 ================== * Added many examples * Added; compiler api is now public * Added; filters can accept / manipulate the parse tree * Added filter attribute support. Closes #79 * Added LL(*) capabilities * Performance; wrapping code blocks in {} instead of `(function(){}).call(this)` * Performance; Optimized attribute buffering * Fixed trailing newlines in blocks 0.5.0 / 2010-09-11 ================== * __Major__ refactor. Logic now separated into lexer/parser/compiler for future extensibility. * Added _pretty_ option * Added parse tree output for _debug_ option * Added new examples * Removed _context_ option, use _scope_ 0.4.1 / 2010-09-09 ================== * Added support for arbitrary indentation for single-line comments. Closes #71 * Only strip first space in text (ex '| foo' will buffer ' foo') 0.4.0 / 2010-08-30 ================== * Added tab naive support (tabs are converted to a single indent, aka two spaces). Closes #24 * Added unbuffered comment support. Closes #62 * Added hyphen support for tag names, ex: "fb:foo-bar" * Fixed bug with single quotes in comments. Closes #61 * Fixed comment whitespace issue, previously padding. Closes #55 0.3.0 / 2010-08-04 ================== * Added single line comment support. Closes #25 * Removed CDATA from _:javascript_ filter. Closes #47 * Removed _sys_ local * Fixed code following tag 0.2.4 / 2010-08-02 ================== * Added Buffer support to `render()` * Fixed filter text block exception reporting * Fixed tag exception reporting 0.2.3 / 2010-07-27 ================== * Fixed newlines before block * Fixed; tag text allowing arbitrary trailing whitespace 0.2.2 / 2010-07-16 ================== * Added support for `jade.renderFile()` to utilize primed cache * Added link to [textmate bundle](http://github.com/miksago/jade-tmbundle) * Fixed filter issue with single quotes * Fixed hyphenated attr bug * Fixed interpolation single quotes. Closes #28 * Fixed issue with comma in attrs 0.2.1 / 2010-07-09 ================== * Added support for node-discount and markdown-js depending on which is available. * Added support for tags to have blocks _and_ text. this kinda fucks with arbitrary whitespace unfortunately, but also fixes trailing spaces after tags _with_ blocks. * Caching generated functions. Closes #46 0.2.0 / 2010-07-08 ================== * Added `- each` support for readable iteration * Added [markdown-js](http://github.com/evilstreak/markdown-js) support (no compilation required) * Removed node-discount support 0.1.0 / 2010-07-05 ================== * Added `${}` support for interpolation. Closes #45 * Added support for quoted attr keys: `label("for": 'something')` is allowed (_although not required_) [Guillermo] * Added `:less` filter [jakeluer] 0.0.2 / 2010-07-03 ================== * Added `context` as synonym for `scope` option [Guillermo] * Fixed attr splitting: `div(style:"color: red")` is now allowed * Fixed issue with `(` and `)` within attrs: `a(class: (a ? 'a' : 'b'))` is now allowed * Fixed issue with leading / trailing spaces in attrs: `a( href="#" )` is now allowed [Guillermo] node-jade-1.5.0+dfsg/LICENSE000066400000000000000000000021171237002143700152670ustar00rootroot00000000000000(The MIT License) Copyright (c) 2009-2014 TJ Holowaychuk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. node-jade-1.5.0+dfsg/README.md000066400000000000000000000114131237002143700155400ustar00rootroot00000000000000# [![Jade - template engine ](http://i.imgur.com/5zf2aVt.png)](http://jade-lang.com/) Full documentation is at [jade-lang.com](http://jade-lang.com/) Jade is a high performance template engine heavily influenced by [Haml](http://haml-lang.com) and implemented with JavaScript for [node](http://nodejs.org). For discussion join the [Google Group](http://groups.google.com/group/jadejs). You can test drive Jade online [here](http://naltatis.github.com/jade-syntax-docs). [![Build Status](https://img.shields.io/travis/visionmedia/jade/master.svg)](https://travis-ci.org/visionmedia/jade) [![Dependency Status](https://img.shields.io/gemnasium/visionmedia/jade.svg)](https://gemnasium.com/visionmedia/jade) [![NPM version](https://img.shields.io/npm/v/jade.svg)](http://badge.fury.io/js/jade) ## Installation via npm: ```bash $ npm install jade ``` ## Syntax Jade is a clean, whitespace sensitive syntax for writing html. Here is a simple example: ```jade doctype html html(lang="en") head title= pageTitle script(type='text/javascript'). if (foo) bar(1 + 5) body h1 Jade - node template engine #container.col if youAreUsingJade p You are amazing else p Get on it! p. Jade is a terse and simple templating language with a strong focus on performance and powerful features. ``` becomes ```html Jade

Jade - node template engine

You are amazing

Jade is a terse and simple templating language with a strong focus on performance and powerful features.

``` 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) ## API For full API, see [jade-lang.com/api](http://jade-lang.com/api/) ```js var jade = require('jade'); // compile var fn = jade.compile('string of jade', options); var html = fn(locals); // render var html = jade.render('string of jade', merge(options, locals)); // renderFile var html = jade.renderFile('filename.jade', merge(options, locals)); ``` ### Options - `filename` Used in exceptions, and required when using includes - `compileDebug` When `false` no debug instrumentation is compiled - `pretty` Add pretty-indentation whitespace to output _(false by default)_ ## Browser Support 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. To compile a template for use on the client using the command line, do: ```console $ jade --client --no-debug filename.jade ``` which will produce `filename.js` containing the compiled template. ## Command Line After installing the latest version of [node](http://nodejs.org/), install with: ```console $ npm install jade -g ``` and run with ```console $ jade --help ``` ## Additional Resources Tutorials: - cssdeck interactive [Jade syntax tutorial](http://cssdeck.com/labs/learning-the-jade-templating-engine-syntax) - cssdeck interactive [Jade logic tutorial](http://cssdeck.com/labs/jade-templating-tutorial-codecast-part-2) - [Jade について。](https://gist.github.com/japboy/5402844) (A Japanese Tutorial) - [Jade - 模板引擎](https://github.com/visionmedia/jade/blob/master/Readme_zh-cn.md) Implementations in other languages: - [php](http://github.com/everzet/jade.php) - [scala](http://scalate.fusesource.org/versions/snapshot/documentation/scaml-reference.html) - [ruby](https://github.com/slim-template/slim) - [python](https://github.com/SyrusAkbary/pyjade) - [java](https://github.com/neuland/jade4j) Other: - [Emacs Mode](https://github.com/brianc/jade-mode) - [Vim Syntax](https://github.com/digitaltoad/vim-jade) - [TextMate Bundle](http://github.com/miksago/jade-tmbundle) - [Coda/SubEtha syntax Mode](https://github.com/aaronmccall/jade.mode) - [Screencasts](http://tjholowaychuk.com/post/1004255394/jade-screencast-template-engine-for-nodejs) - [html2jade](https://github.com/donpark/html2jade) converter - [Jade Server](https://github.com/ded/jade-server) Ideal for building local prototypes apart from any application ## License MIT node-jade-1.5.0+dfsg/Readme_zh-cn.md000066400000000000000000000706141237002143700171070ustar00rootroot00000000000000# Jade - 模板引擎 Jade 是一个高性能的模板引擎,它深受 [Haml](http://haml-lang.com) 影响,它是用 JavaScript 实现的, 并且可以供 [Node](http://nodejs.org) 使用. 翻译: [草依山](http://jser.me) 等 ## 声明 从 Jade `v0.31.0` 开始放弃了对于 `" | !{html} ``` 内联标签同样可以使用文本块来包含文本: ```jade label | Username: input(name='user[name]') ``` 或者直接使用标签文本: ```jade label Username: input(name='user[name]') ``` _只_ 包含文本的标签,比如 `

My Site

Welcome to my super lame site.

``` 前面已经提到,`include` 可以包含比如 HTML 或者 CSS 这样的内容。给定一个扩展名后,Jade 不会把这个文件当作一个 Jade 源代码,并且会把它当作一个普通文本包含进来: ``` html head //- css and js have simple filters that wrap them in

My Site

Welcome to my super lame site.

h2 Including Filtered Text p You can combine filters with includes to filter things as you include them. .row .col-lg-6 +jade :jadesrc //- index.jade doctype html html head title An Article body include:markdown article.md +jade :verbatim # article.md This is an article written in markdown. .col-lg-6 +html :htmlsrc An Article

article.md

This is an article written in markdown.

node-jade-1.5.0+dfsg/docs/views/reference/iteration.jade000066400000000000000000000036271237002143700231370ustar00rootroot00000000000000extends ../reference.jade block documentation h1 Iteration p Jade supports two primary methods of iteration, #[code each] and #[code while]. h2 each p. Jade's first-class iteration syntax makes it easier to iterate over arrays and objects within a template: .row(data-control='interactive') .col-lg-6 +jade :jadesrc ul each val in [1, 2, 3, 4, 5] li= val .col-lg-6 +html :htmlsrc
  • 1
  • 2
  • 3
  • 4
  • 5
p You can also get the index as you iterate: .row(data-control='interactive') .col-lg-6 +jade :jadesrc ul each val, index in ['zero', 'one', 'two'] li= index + ': ' + val .col-lg-6 +html :htmlsrc
  • 0: zero
  • 1: one
  • 2: two
p Jade also lets you iterate over the keys in an object: .row(data-control='interactive') .col-lg-6 +jade :jadesrc ul each val, index in {1:'one',2:'two',3:'three'} li= index + ': ' + val .col-lg-6 +html :htmlsrc
  • 1: one
  • 2: two
  • 3: three
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. h2 while p You can also use #[code while] to create a loop: .row(data-control='interactive') .col-lg-6 +jade :jadesrc - var n = 0 ul while n < 4 li= n++ .col-lg-6 +html :htmlsrc
  • 0
  • 1
  • 2
  • 3
node-jade-1.5.0+dfsg/docs/views/reference/mixins.jade000066400000000000000000000052121237002143700224400ustar00rootroot00000000000000extends ../reference.jade block documentation h1 Mixins p Mixins allow you to create reusable blocks of jade. .row(data-control='interactive') .col-lg-6 +jade :jadesrc //- Declaration mixin list ul li foo li bar li baz //- Use +list +list .col-lg-6 +html :htmlsrc
  • foo
  • bar
  • baz
  • foo
  • bar
  • baz
p They are compiled to functions and can take arguments: .row(data-control='interactive') .col-lg-6 +jade :jadesrc mixin pet(name) li.pet= name ul +pet('cat') +pet('dog') +pet('pig') .col-lg-6 +html :htmlsrc
  • cat
  • dog
  • pig
h2 Mixin Blocks p Mixins can also take a block of jade to act as the content: .row(data-control='interactive') .col-lg-6 +jade :jadesrc 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 .col-lg-6 +html :htmlsrc

Hello world

No content provided

Hello world

This is my

Amazing article

h2 Mixin Attributes p Mixins also get an implicit attributes argument taken from the attributes passed to the mixin: .row(data-control='interactive') .col-lg-6 +jade :jadesrc mixin link(href, name) //- attributes == {class: "btn"} a(class!=attributes.class, href=href)= name +link('/foo', 'foo')(class="btn") .col-lg-6 +html :htmlsrc foo .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. node-jade-1.5.0+dfsg/docs/views/reference/plain-text.jade000066400000000000000000000032021237002143700232130ustar00rootroot00000000000000extends ../reference.jade block documentation h1 Plain Text p Jade provides three common ways of getting plain text. They are useful in different situations h2 Piped Text p The simplest way of adding plain text to templates is to prefix the line with a | character (pronounced "pipe"). .row(data-control='interactive') .col-lg-6 +jade :jadesrc | Plain text can include html p | It must always be on its own line .col-lg-6 +html :htmlsrc Plain text can include html

It must always be on its own line

h2 Inline in a Tag p Since it's a common use case, you can put text in a tag just by adding it inline after a space. .row(data-control='interactive') .col-lg-6 +jade :jadesrc p Plain text can include html .col-lg-6 +html :htmlsrc

Plain text can include html

h2 Block in a Tag p Often you might want large blocks of text within a tag. A good example is with inline scripts or styles. To do this, just add a . after the tag (with no preceding space): .row(data-control='interactive') .col-lg-6 +jade :jadesrc script. if (usingJade) console.log('you are awesome') else console.log('use jade') .col-lg-6 +html :htmlsrc node-jade-1.5.0+dfsg/docs/views/reference/tags.jade000066400000000000000000000017471237002143700221000ustar00rootroot00000000000000extends ../reference.jade block documentation h1 Tags p By default, text at the start of a line (or after only white space) represents an html tag. Indented tags are nested, creating the tree like structure of html. .row(data-control='interactive') .col-lg-6 +jade :jadesrc ul li Item A li Item B li Item C .col-lg-6 +html :htmlsrc
  • Item A
  • Item B
  • Item C
p Jade also knows which elements are self closing: .row(data-control='interactive') .col-lg-6 +jade :jadesrc img .col-lg-6 +html :htmlsrc h2 Block Expansion p To save space, jade provides an inline syntax for nested tags. .row(data-control='interactive') .col-lg-6 +jade :jadesrc a: img .col-lg-6 +html :htmlsrc node-jade-1.5.0+dfsg/examples/000077500000000000000000000000001237002143700160775ustar00rootroot00000000000000node-jade-1.5.0+dfsg/examples/README.md000066400000000000000000000002151237002143700173540ustar00rootroot00000000000000The examples in this directory can be run simply by something like. node attributes.js You can also open `browser.html` in a browser. node-jade-1.5.0+dfsg/examples/attributes.jade000066400000000000000000000004361237002143700211150ustar00rootroot00000000000000div#id.left.container(class='user user-' + name) h1.title= name form //- unbuffered comment :) // An example of attributes. input(type='text' name='user[name]' value=name) input(checked, type='checkbox', name='user[blocked]') input(type='submit', value='Update')node-jade-1.5.0+dfsg/examples/attributes.js000066400000000000000000000003721237002143700206250ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../') , path = __dirname + '/attributes.jade' , str = require('fs').readFileSync(path, 'utf8') , fn = jade.compile(str, { filename: path, pretty: true }); console.log(fn({ name: 'tj' }));node-jade-1.5.0+dfsg/examples/code.jade000066400000000000000000000004051237002143700176350ustar00rootroot00000000000000 - var title = "Things" h1= title ul#users each user, name in users // expands to if (user.isA == 'ferret') if user.isA == 'ferret' li(class='user-' + name) #{name} is just a ferret else li(class='user-' + name) #{name} #{user.email}node-jade-1.5.0+dfsg/examples/code.js000066400000000000000000000006061237002143700173510ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../') , path = __dirname + '/code.jade' , str = require('fs').readFileSync(path, 'utf8') , fn = jade.compile(str, { filename: path, pretty: true }); var users = { tj: { age: 23, email: 'tj@vision-media.ca', isA: 'human' }, tobi: { age: 1, email: 'tobi@is-amazing.com', isA: 'ferret' } }; console.log(fn({ users: users }));node-jade-1.5.0+dfsg/examples/csrf.jade000066400000000000000000000002311237002143700176550ustar00rootroot00000000000000 form(method='post', action='/') input(type='text', name='user[name]') input(type='text', name='user[email]') input(type='submit', value='Submit') node-jade-1.5.0+dfsg/examples/csrf.js000066400000000000000000000015571237002143700174020ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../lib/jade'), Compiler = jade.Compiler, nodes = jade.nodes; var options = { compiler: CSRF , locals: { csrf: 'WAHOOOOOO' } }; jade.renderFile(__dirname + '/csrf.jade', options, function(err, html){ if (err) throw err; console.log(html); }); function CSRF(node, options) { Compiler.call(this, node, options); } CSRF.prototype.__proto__ = Compiler.prototype; CSRF.prototype.visitTag = function(node){ var parent = Compiler.prototype.visitTag; switch (node.name) { case 'form': if ("'post'" == node.getAttribute('method')) { var tok = new nodes.Tag('input'); tok.setAttribute('type', '"hidden"'); tok.setAttribute('name', '"csrf"'); tok.setAttribute('value', 'csrf'); node.block.unshift(tok); } } parent.call(this, node); }; node-jade-1.5.0+dfsg/examples/dynamicscript.jade000066400000000000000000000001771237002143700216020ustar00rootroot00000000000000html head title Dynamic Inline JavaScript script. var users = !{JSON.stringify(users).replace(/<\//g, "<\\/")} node-jade-1.5.0+dfsg/examples/dynamicscript.js000066400000000000000000000006401237002143700213060ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../lib/jade'); var options = { locals: { users: { tj: { age: 23, email: 'tj@vision-media.ca', isA: 'human' }, tobi: { age: 1, email: 'tobi@is-amazing.com', isA: 'ferret' } } } }; jade.renderFile(__dirname + '/dynamicscript.jade', options, function(err, html){ if (err) throw err; console.log(html); });node-jade-1.5.0+dfsg/examples/each.jade000066400000000000000000000001261237002143700176230ustar00rootroot00000000000000ul#users each user, name in users li(class='user-' + name) #{name} #{user.email}node-jade-1.5.0+dfsg/examples/each.js000066400000000000000000000006061237002143700173370ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../') , path = __dirname + '/each.jade' , str = require('fs').readFileSync(path, 'utf8') , fn = jade.compile(str, { filename: path, pretty: true }); var users = { tj: { age: 23, email: 'tj@vision-media.ca', isA: 'human' }, tobi: { age: 1, email: 'tobi@is-amazing.com', isA: 'ferret' } }; console.log(fn({ users: users }));node-jade-1.5.0+dfsg/examples/extend-layout.jade000066400000000000000000000002521237002143700215250ustar00rootroot00000000000000html head h1 My Site - #{title} block scripts script(src='/jquery.js') body block content block foot #footer p some footer contentnode-jade-1.5.0+dfsg/examples/extend.jade000066400000000000000000000002271237002143700202140ustar00rootroot00000000000000 extends extend-layout block scripts script(src='/jquery.js') script(src='/pets.js') block content h1= title each pet in pets include petnode-jade-1.5.0+dfsg/examples/extend.js000066400000000000000000000006121237002143700177230ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../') , path = __dirname + '/extend.jade' , str = require('fs').readFileSync(path, 'utf8') , fn = jade.compile(str, { filename: path, pretty: true }); var tobi = { name: 'tobi', age: 2 }; var loki = { name: 'loki', age: 1 }; var jane = { name: 'jane', age: 5 }; console.log(fn({ title: 'pets' , pets: [tobi, loki, jane] }));node-jade-1.5.0+dfsg/examples/form.jade000066400000000000000000000015561237002143700176760ustar00rootroot00000000000000form(method="post") fieldset legend General p label(for="user[name]") Username: input(type="text", name="user[name]", value=user.name) p label(for="user[email]") Email: input(type="text", name="user[email]", value=user.email) .tip. Enter a valid email address such as tj@vision-media.ca. fieldset legend Location p label(for="user[city]") City: input(type="text", name="user[city]", value=user.city) p select(name="user[province]") option(value="") -- Select Province -- option(value="AB") Alberta option(value="BC") British Columbia option(value="SK") Saskatchewan option(value="MB") Manitoba option(value="ON") Ontario option(value="QC") Quebec p.buttons input(type="submit", value="Save")node-jade-1.5.0+dfsg/examples/form.js000066400000000000000000000005251237002143700174020ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('../') , path = __dirname + '/form.jade' , str = require('fs').readFileSync(path, 'utf8') , fn = jade.compile(str, { filename: path, pretty: true }); var user = { name: 'TJ', email: 'tj@vision-media.ca', city: 'Victoria', province: 'BC' }; console.log(fn({ user: user }));node-jade-1.5.0+dfsg/examples/includes.jade000066400000000000000000000001621237002143700205310ustar00rootroot00000000000000 html include includes/head body h1 My Site p Welcome to my super lame site. include includes/footnode-jade-1.5.0+dfsg/examples/includes.js000066400000000000000000000003521237002143700202430ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../') , path = __dirname + '/includes.jade' , str = require('fs').readFileSync(path, 'utf8') , fn = jade.compile(str, { filename: path, pretty: true }); console.log(fn());node-jade-1.5.0+dfsg/examples/includes/000077500000000000000000000000001237002143700177055ustar00rootroot00000000000000node-jade-1.5.0+dfsg/examples/includes/foot.jade000066400000000000000000000000401237002143700214730ustar00rootroot00000000000000#footer p Copyright (c) foobarnode-jade-1.5.0+dfsg/examples/includes/head.jade000066400000000000000000000002001237002143700214230ustar00rootroot00000000000000head title My Site // including other jade works include scripts // including .html, .css, etc works include style.cssnode-jade-1.5.0+dfsg/examples/includes/scripts.jade000066400000000000000000000001071237002143700222170ustar00rootroot00000000000000script(src='/javascripts/jquery.js') script(src='/javascripts/app.js') node-jade-1.5.0+dfsg/examples/includes/style.css000066400000000000000000000000601237002143700215530ustar00rootroot00000000000000node-jade-1.5.0+dfsg/examples/layout-debug.js000066400000000000000000000003141237002143700210340ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../lib/jade'); jade.renderFile(__dirname + '/layout.jade', { debug: true }, function(err, html){ if (err) throw err; console.log(html); });node-jade-1.5.0+dfsg/examples/layout.jade000066400000000000000000000005711237002143700202440ustar00rootroot00000000000000doctype html html(lang="en") head title Example script. if (foo) { bar(); } body h1 Jade - node template engine #container :markdown Jade is a _high performance_ template engine for [node](http://nodejs.org), inspired by [haml](http://haml-lang.com/), and written by [TJ Holowaychuk](http://github.com/visionmedia).node-jade-1.5.0+dfsg/examples/layout.js000066400000000000000000000003501237002143700177500ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../') , path = __dirname + '/layout.jade' , str = require('fs').readFileSync(path, 'utf8') , fn = jade.compile(str, { filename: path, pretty: true }); console.log(fn());node-jade-1.5.0+dfsg/examples/mixins.jade000066400000000000000000000003031237002143700202270ustar00rootroot00000000000000 include mixins/dialog include mixins/profile .one mixin dialog .two mixin dialog-title('Whoop') .three mixin dialog-title-desc('Whoop', 'Just a mixin') #profile mixin profile(user) node-jade-1.5.0+dfsg/examples/mixins.js000066400000000000000000000005021237002143700177410ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../') , path = __dirname + '/mixins.jade' , str = require('fs').readFileSync(path, 'utf8') , fn = jade.compile(str, { filename: path, pretty: true }); var user = { name: 'tj' , pets: ['tobi', 'loki', 'jane', 'manny'] }; console.log(fn({ user: user }));node-jade-1.5.0+dfsg/examples/mixins/000077500000000000000000000000001237002143700174065ustar00rootroot00000000000000node-jade-1.5.0+dfsg/examples/mixins/dialog.jade000066400000000000000000000002721237002143700214730ustar00rootroot00000000000000 mixin dialog .dialog h1 Whoop p stuff mixin dialog-title(title) .dialog h1= title p stuff mixin dialog-title-desc(title, desc) .dialog h1= title p= desc node-jade-1.5.0+dfsg/examples/mixins/profile.jade000066400000000000000000000002111237002143700216650ustar00rootroot00000000000000 mixin pets(pets) ul.pets - each pet in pets li= pet mixin profile(user) .user h2= user.name mixin pets(user.pets)node-jade-1.5.0+dfsg/examples/pet.jade000066400000000000000000000001071237002143700175120ustar00rootroot00000000000000.pet h2= pet.name p #{pet.name} is #{pet.age} year(s) old.node-jade-1.5.0+dfsg/examples/rss.jade000066400000000000000000000005011237002143700175270ustar00rootroot00000000000000doctype xml rss(version='2.0') channel title RSS Title description Some description here link http://google.com lastBuildDate Mon, 06 Sep 2010 00:01:00 +0000 pubDate Mon, 06 Sep 2009 16:45:00 +0000 each item in items item title= item.title description= item.description link= item.link node-jade-1.5.0+dfsg/examples/rss.js000066400000000000000000000010141237002143700172400ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../') , path = __dirname + '/rss.jade' , str = require('fs').readFileSync(path, 'utf8') , fn = jade.compile(str, { filename: path, pretty: true }); var items = []; items.push({ title: 'Example', description: 'Something', link: 'http://google.com' }); items.push({ title: 'LearnBoost', description: 'Cool', link: 'http://learnboost.com' }); items.push({ title: 'Express', description: 'Cool', link: 'http://expressjs.com' }); console.log(fn({ items: items }));node-jade-1.5.0+dfsg/examples/text.jade000066400000000000000000000013751237002143700177160ustar00rootroot00000000000000| An example of an a(href='#') inline | link. form label Username: input(type='text', name='user[name]') p | Just an example of some text usage. | You can have inline html, | as well as strong tags | . | Interpolation is also supported. The | username is currently "#{name}". label Email: input(type='text', name='user[email]') p | Email is currently em= email | . // alternatively, if we plan on having only // text or inline-html, we can use a trailing // "." to let jade know we want to omit pipes label Username: input(type='text') p. Just an example, like before however now we can omit those annoying pipes!. Wahoo.node-jade-1.5.0+dfsg/examples/text.js000066400000000000000000000004211237002143700174160ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../') , path = __dirname + '/text.jade' , str = require('fs').readFileSync(path, 'utf8') , fn = jade.compile(str, { filename: path, pretty: true }); console.log(fn({ name: 'tj', email: 'tj@vision-media.ca' }));node-jade-1.5.0+dfsg/examples/whitespace.jade000066400000000000000000000001761237002143700210640ustar00rootroot00000000000000- var js = '' doctype html html head title= "Some " + "JavaScript" != js body node-jade-1.5.0+dfsg/examples/whitespace.js000066400000000000000000000003541237002143700205730ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('./../') , path = __dirname + '/whitespace.jade' , str = require('fs').readFileSync(path, 'utf8') , fn = jade.compile(str, { filename: path, pretty: true }); console.log(fn());node-jade-1.5.0+dfsg/index.js000066400000000000000000000000511237002143700157220ustar00rootroot00000000000000 module.exports = require('./lib/jade'); node-jade-1.5.0+dfsg/jade-language.md000066400000000000000000000500121237002143700172650ustar00rootroot00000000000000 ## Syntax ### Tags A tag is simply a leading word: ```jade html ``` for example is converted to `` tags can also have ids: ```jade div#container ``` which would render `
` how about some classes? ```jade div.user-details ``` renders `
` multiple classes? _and_ an id? sure: ```jade div#foo.bar.baz ``` renders `
` 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
```
### Tag Text Simply place some content after the tag: ```jade p wahoo! ``` renders `

wahoo!

`. well cool, but how about large bodies of text: ```jade p | foo bar baz | rawr rawr | super cool | go jade go ``` renders `

foo bar baz rawr.....

` interpolation? yup! both types of text can utilize interpolation, if we passed `{ name: 'tj', email: 'tj@vision-media.ca' }` to the compiled function we can do the following: ```jade #user #{name} <#{email}> ``` outputs `
tj <tj@vision-media.ca>
` Actually want `#{}` for some reason? escape it! ```jade p \#{something} ``` now we have `

#{something}

` We can also utilize the unescaped variant `!{html}`, so the following will result in a literal script tag: ```jade - var html = "" | !{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

foo asdf asdf asdfasdfaf asdf asd.

``` 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

.

``` It should be noted that text blocks should be doubled escaped. For example if you desire the following output. ```html

foo\bar

``` use: ```jade p. foo\\bar ```
### 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

foo

bar

``` Jade also supports unbuffered comments, by simply adding a hyphen: ```jade //- will not output within markup p foo p bar ``` outputting ```html

foo

bar

```
### Block Comments A block comment is legal as well: ```jade body // #content h1 Example ``` outputting ```html ``` Jade supports conditional-comments as well, for example: ```jade head //if lt IE 8 script(src='/ie-sucks.js') ``` outputs: ```html ``` ### 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 ``` ### 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 ``` ### 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 ``` ### 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) ``` ### HTML Inline html is fine, we can use the pipe syntax to write arbitrary text, in this case some html: ```jade html body |

Title

|

foo bar baz

``` 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.

Title

foo bar baz

``` Both of these examples yield the same result: ```html

Title

foo bar baz

``` The same rule applies for anywhere you can have text in jade, raw html is fine: ```jade html body h1 User #{name} ```
### 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 ``` Below are the doctypes defined by default, which can easily be extended: ```js var doctypes = exports.doctypes = { '5': '', 'default': '', 'xml': '', 'transitional': '', 'strict': '', 'frameset': '', '1.1': '', 'basic': '', 'mobile': '' }; ``` To alter the default simply change: ```js jade.doctypes.default = 'whatever you want'; ``` ## 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

Woah! jade and markdown, very cool we can even link to stuff

``` ## 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

bar

`. 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 ```
## 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
  • one
  • two
  • three
  • ``` iterating an array with index: ```jade items = ["one", "two", "three"] each item, i in items li #{item}: #{i} ``` outputs: ```html
  • one: 0
  • two: 1
  • three: 2
  • ``` iterating an object's keys and values: ```jade obj = { foo: 'bar' } each val, key in obj li #{key}: #{val} ``` would output `
  • foo: bar
  • ` 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 ```
    ## 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 ``` ## 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 ``` ## 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') ``` ## 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 My Site

    My Site

    Welcome to my super lame site.

    ``` 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 node-jade-1.5.0+dfsg/test/cases/filters.less.jade000066400000000000000000000001711237002143700215770ustar00rootroot00000000000000html head style(type="text/css") :less @pad: 15px; body { padding: @pad; } node-jade-1.5.0+dfsg/test/cases/filters.markdown.html000066400000000000000000000001461237002143700225160ustar00rootroot00000000000000

    This is some awesome markdown whoop.

    node-jade-1.5.0+dfsg/test/cases/filters.markdown.jade000066400000000000000000000001201237002143700224450ustar00rootroot00000000000000html body :markdown This is _some_ awesome **markdown** whoop.node-jade-1.5.0+dfsg/test/cases/filters.stylus.html000066400000000000000000000001521237002143700222340ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/filters.stylus.jade000066400000000000000000000001411237002143700221710ustar00rootroot00000000000000html head style(type="text/css") :stylus body padding: 50px body node-jade-1.5.0+dfsg/test/cases/html.html000066400000000000000000000001351237002143700201670ustar00rootroot00000000000000
    • foo
    • bar
    • baz

    You can embed html as well.

    node-jade-1.5.0+dfsg/test/cases/html.jade000066400000000000000000000001321237002143700201230ustar00rootroot00000000000000
    • foo
    • bar
    • baz
    p You can embed html as well.node-jade-1.5.0+dfsg/test/cases/html5.html000066400000000000000000000001471237002143700202570ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/html5.jade000066400000000000000000000001671237002143700202200ustar00rootroot00000000000000doctype html input(type='checkbox', checked) input(type='checkbox', checked=true) input(type='checkbox', checked=false)node-jade-1.5.0+dfsg/test/cases/include-extends-from-root.html000066400000000000000000000001511237002143700242360ustar00rootroot00000000000000 My Application

    hello

    node-jade-1.5.0+dfsg/test/cases/include-extends-from-root.jade000066400000000000000000000000441237002143700241760ustar00rootroot00000000000000include /auxiliary/extends-from-rootnode-jade-1.5.0+dfsg/test/cases/include-extends-of-common-template.html000066400000000000000000000000421237002143700260140ustar00rootroot00000000000000
    test1
    test2
    node-jade-1.5.0+dfsg/test/cases/include-extends-of-common-template.jade000066400000000000000000000001201237002143700257500ustar00rootroot00000000000000include auxiliary/extends-empty-block-1 include auxiliary/extends-empty-block-2 node-jade-1.5.0+dfsg/test/cases/include-filter-coffee.coffee000066400000000000000000000000521237002143700236370ustar00rootroot00000000000000math = square: (value) -> value * value node-jade-1.5.0+dfsg/test/cases/include-filter-stylus.html000066400000000000000000000000721237002143700234720ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/include-filter-stylus.jade000066400000000000000000000000601237002143700234260ustar00rootroot00000000000000style(type="text/css") include:styl some.styl node-jade-1.5.0+dfsg/test/cases/include-filter.html000066400000000000000000000005461237002143700221370ustar00rootroot00000000000000

    Just some markdown tests.

    With new line.

    node-jade-1.5.0+dfsg/test/cases/include-filter.jade000066400000000000000000000002701237002143700220700ustar00rootroot00000000000000html body include:md some.md script include:coffee(minify=true) include-filter-coffee.coffee script include:coffee(minify=false) include-filter-coffee.coffee node-jade-1.5.0+dfsg/test/cases/include-only-text-body.html000066400000000000000000000000211237002143700235340ustar00rootroot00000000000000The message is ""node-jade-1.5.0+dfsg/test/cases/include-only-text-body.jade000066400000000000000000000000351237002143700235000ustar00rootroot00000000000000| The message is " yield | " node-jade-1.5.0+dfsg/test/cases/include-only-text.html000066400000000000000000000001221237002143700226030ustar00rootroot00000000000000

    The message is "hello world"

    node-jade-1.5.0+dfsg/test/cases/include-only-text.jade000066400000000000000000000001161237002143700225450ustar00rootroot00000000000000html body p include include-only-text-body em hello world node-jade-1.5.0+dfsg/test/cases/include-with-text-head.html000066400000000000000000000001161237002143700234770ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/include-with-text-head.jade000066400000000000000000000001011237002143700234300ustar00rootroot00000000000000head script(type='text/javascript'). alert('hello world'); node-jade-1.5.0+dfsg/test/cases/include-with-text.html000066400000000000000000000002571237002143700226060ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/include-with-text.jade000066400000000000000000000001361237002143700225410ustar00rootroot00000000000000html include include-with-text-head script(src='/caustic.js') script(src='/app.js') node-jade-1.5.0+dfsg/test/cases/include.script.html000066400000000000000000000002471237002143700221550ustar00rootroot00000000000000node-jade-1.5.0+dfsg/test/cases/include.script.jade000066400000000000000000000001031237002143700221030ustar00rootroot00000000000000script#pet-template(type='text/x-template') include auxiliary/petnode-jade-1.5.0+dfsg/test/cases/include.yield.nested.html000066400000000000000000000004321237002143700232340ustar00rootroot00000000000000

    Page

    some content

    and some more

    node-jade-1.5.0+dfsg/test/cases/include.yield.nested.jade000066400000000000000000000001021237002143700231650ustar00rootroot00000000000000 include auxiliary/yield-nested p some content p and some morenode-jade-1.5.0+dfsg/test/cases/includes-with-ext-js.html000066400000000000000000000001061237002143700232100ustar00rootroot00000000000000
    var x = "\n here is some \n new lined text";
    
    node-jade-1.5.0+dfsg/test/cases/includes-with-ext-js.jade000066400000000000000000000000571237002143700231540ustar00rootroot00000000000000pre code include javascript-new-lines.js node-jade-1.5.0+dfsg/test/cases/includes.html000066400000000000000000000004161237002143700210330ustar00rootroot00000000000000

    bar

    :)

    node-jade-1.5.0+dfsg/test/cases/includes.jade000066400000000000000000000002561237002143700207740ustar00rootroot00000000000000 include auxiliary/mixins +foo body include auxiliary/smile.html include auxiliary/escapes.html script(type="text/javascript") include:js auxiliary/includable.js node-jade-1.5.0+dfsg/test/cases/inheritance.alert-dialog.html000066400000000000000000000002131237002143700240540ustar00rootroot00000000000000
    Close

    Alert!

    I'm an alert!

    node-jade-1.5.0+dfsg/test/cases/inheritance.alert-dialog.jade000066400000000000000000000001061237002143700240140ustar00rootroot00000000000000 extends auxiliary/dialog block content h1 Alert! p I'm an alert!node-jade-1.5.0+dfsg/test/cases/inheritance.defaults.html000066400000000000000000000002271237002143700233240ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/inheritance.defaults.jade000066400000000000000000000001701237002143700232600ustar00rootroot00000000000000html head block head script(src='jquery.js') script(src='keymaster.js') script(src='caustic.js')node-jade-1.5.0+dfsg/test/cases/inheritance.extend.html000066400000000000000000000002461237002143700230050ustar00rootroot00000000000000 My Application

    Page

    Some content

    node-jade-1.5.0+dfsg/test/cases/inheritance.extend.include.html000066400000000000000000000004641237002143700244310ustar00rootroot00000000000000 My Application

    Page

    Some content

    Close

    Awesome

    Now we can extend included blocks!

    node-jade-1.5.0+dfsg/test/cases/inheritance.extend.include.jade000066400000000000000000000002721237002143700243650ustar00rootroot00000000000000 extend auxiliary/layout.include block head script(src='jquery.js') block content h2 Page p Some content block window-content h2 Awesome p Now we can extend included blocks!node-jade-1.5.0+dfsg/test/cases/inheritance.extend.jade000066400000000000000000000001501237002143700227360ustar00rootroot00000000000000 extend auxiliary/layout block head script(src='jquery.js') block content h2 Page p Some contentnode-jade-1.5.0+dfsg/test/cases/inheritance.extend.mixins.block.html000066400000000000000000000002161237002143700254010ustar00rootroot00000000000000 My Application

    Hello World!

    node-jade-1.5.0+dfsg/test/cases/inheritance.extend.mixins.block.jade000066400000000000000000000001201237002143700253320ustar00rootroot00000000000000extend auxiliary/inheritance.extend.mixin.block block content p Hello World! node-jade-1.5.0+dfsg/test/cases/inheritance.extend.mixins.html000066400000000000000000000002171237002143700243110ustar00rootroot00000000000000 My Application

    The meaning of life

    Foo bar baz!

    node-jade-1.5.0+dfsg/test/cases/inheritance.extend.mixins.jade000066400000000000000000000002231237002143700242450ustar00rootroot00000000000000 extend auxiliary/layout mixin article(title) if title h1= title block block content +article("The meaning of life") p Foo bar baz!node-jade-1.5.0+dfsg/test/cases/inheritance.extend.recursive.html000066400000000000000000000001161237002143700250070ustar00rootroot00000000000000

    grand-grandparent

    grandparent

    parent

    child

    node-jade-1.5.0+dfsg/test/cases/inheritance.extend.recursive.jade000066400000000000000000000001261237002143700247470ustar00rootroot00000000000000extends /auxiliary/inheritance.extend.recursive-parent.jade block parent h4 childnode-jade-1.5.0+dfsg/test/cases/inheritance.extend.whitespace.html000066400000000000000000000002461237002143700251400ustar00rootroot00000000000000 My Application

    Page

    Some content

    node-jade-1.5.0+dfsg/test/cases/inheritance.extend.whitespace.jade000066400000000000000000000001641237002143700250760ustar00rootroot00000000000000 extend auxiliary/layout block head script(src='jquery.js') block content h2 Page p Some contentnode-jade-1.5.0+dfsg/test/cases/inheritance.html000066400000000000000000000002461237002143700215170ustar00rootroot00000000000000 My Application

    Page

    Some content

    node-jade-1.5.0+dfsg/test/cases/inheritance.jade000066400000000000000000000001511237002143700214510ustar00rootroot00000000000000 extends auxiliary/layout block head script(src='jquery.js') block content h2 Page p Some contentnode-jade-1.5.0+dfsg/test/cases/inline-tag.html000066400000000000000000000002651237002143700212560ustar00rootroot00000000000000

    bing foo bong

    bing foo bong

    bingfoobong

    #[strong escaped] #[escaped

    node-jade-1.5.0+dfsg/test/cases/inline-tag.jade000066400000000000000000000002221237002143700212060ustar00rootroot00000000000000p bing #[strong foo] bong p. bing #[strong foo] bong p | bing | #[strong foo] | bong p. \#[strong escaped] \#[#[strong escaped]node-jade-1.5.0+dfsg/test/cases/interpolation.escape.html000066400000000000000000000000641237002143700233520ustar00rootroot00000000000000 some #{text} here My ID is {42} node-jade-1.5.0+dfsg/test/cases/interpolation.escape.jade000066400000000000000000000001211237002143700233030ustar00rootroot00000000000000 - var id = 42; foo | some | \#{text} | here | My ID #{"is {" + id + "}"}node-jade-1.5.0+dfsg/test/cases/javascript-new-lines.js000066400000000000000000000000551237002143700227410ustar00rootroot00000000000000var x = "\n here is some \n new lined text"; node-jade-1.5.0+dfsg/test/cases/layout.append.html000066400000000000000000000003341237002143700220070ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/layout.append.jade000066400000000000000000000001501237002143700217420ustar00rootroot00000000000000 extends ../fixtures/append/app-layout block append head script(src='foo.js') script(src='bar.js') node-jade-1.5.0+dfsg/test/cases/layout.append.without-block.html000066400000000000000000000003341237002143700246010ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/layout.append.without-block.jade000066400000000000000000000001601237002143700245350ustar00rootroot00000000000000 extends ../fixtures/append-without-block/app-layout append head script(src='foo.js') script(src='bar.js') node-jade-1.5.0+dfsg/test/cases/layout.multi.append.prepend.block.html000066400000000000000000000005671237002143700256750ustar00rootroot00000000000000

    Last prepend must appear at top

    Something prepended to content

    Defined content

    Something appended to content

    Last append must be most last

    node-jade-1.5.0+dfsg/test/cases/layout.multi.append.prepend.block.jade000066400000000000000000000006001237002143700256200ustar00rootroot00000000000000extends ../fixtures/multi-append-prepend-block/redefine append content p.first.append Something appended to content prepend content p.first.prepend Something prepended to content append content p.last.append Last append must be most last prepend content p.first.prepend Last prepend must appear at top append head script(src='jquery.js') prepend head script(src='foo.js') node-jade-1.5.0+dfsg/test/cases/layout.prepend.html000066400000000000000000000003341237002143700221750ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/layout.prepend.jade000066400000000000000000000001521237002143700221320ustar00rootroot00000000000000 extends ../fixtures/prepend/app-layout block prepend head script(src='foo.js') script(src='bar.js') node-jade-1.5.0+dfsg/test/cases/layout.prepend.without-block.html000066400000000000000000000003341237002143700247670ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/layout.prepend.without-block.jade000066400000000000000000000001621237002143700247250ustar00rootroot00000000000000 extends ../fixtures/prepend-without-block/app-layout prepend head script(src='foo.js') script(src='bar.js') node-jade-1.5.0+dfsg/test/cases/mixin-hoist.html000066400000000000000000000000631237002143700214730ustar00rootroot00000000000000

    Jade

    node-jade-1.5.0+dfsg/test/cases/mixin-hoist.jade000066400000000000000000000000641237002143700214330ustar00rootroot00000000000000 mixin foo() h1= title html body mixin foo node-jade-1.5.0+dfsg/test/cases/mixin-via-include.html000066400000000000000000000000121237002143700225370ustar00rootroot00000000000000

    bar

    node-jade-1.5.0+dfsg/test/cases/mixin-via-include.jade000066400000000000000000000001661237002143700225100ustar00rootroot00000000000000//- regression test for https://github.com/visionmedia/jade/issues/1435 include ../fixtures/mixin-include.jade +bangnode-jade-1.5.0+dfsg/test/cases/mixin.attrs.html000066400000000000000000000015631237002143700215110ustar00rootroot00000000000000
    Hello World

    Section 1

    Some important content.

    Section 2

    Even more important content.

    Section 3

    Last content.

    Some final words.

    work
    node-jade-1.5.0+dfsg/test/cases/mixin.attrs.jade000066400000000000000000000021241237002143700214420ustar00rootroot00000000000000mixin centered(title) div.centered(id=attributes.id) - if (title) h1(class=attributes.class)= title block - if (attributes.href) .footer a(href=attributes.href) Back mixin main(title) div.stretch +centered(title).highlight&attributes(attributes) block mixin bottom div.bottom&attributes(attributes) block body +centered#First Hello World +centered('Section 1')#Second p Some important content. +centered('Section 2')#Third.foo(href='menu.html', class='bar') p Even more important content. +main('Section 3')(href='#') p Last content. +bottom.foo(class='bar', name='end', id='Last', data-attr='baz') p Some final words. +bottom(class=['class1', 'class2']) mixin foo div.thing(attr1='foo', attr2='bar')&attributes(attributes) - var val = '' - var classes = ['foo', 'bar'] +foo(attr3='baz' data-foo=val data-bar!=val class=classes).thunk //- Regression test for #1424 mixin work_filmstrip_item(work) div&attributes(attributes)= work +work_filmstrip_item('work')("data-profile"='profile', "data-creator-name"='name') node-jade-1.5.0+dfsg/test/cases/mixin.block-tag-behaviour.html000066400000000000000000000005761237002143700242040ustar00rootroot00000000000000

    Foo

    I'm article foo

    Something

    I'm a much longer text-only article, but you can still inline html tags in me if you want.

    node-jade-1.5.0+dfsg/test/cases/mixin.block-tag-behaviour.jade000066400000000000000000000005301237002143700241310ustar00rootroot00000000000000 mixin article(name) section.article h1= name block html body +article('Foo'): p I'm article foo mixin article(name) section.article h1= name p block html body +article('Something'). I'm a much longer text-only article, but you can still inline html tags in me if you want.node-jade-1.5.0+dfsg/test/cases/mixin.blocks.html000066400000000000000000000013621237002143700216260ustar00rootroot00000000000000

    one

    two

    three

    123
    node-jade-1.5.0+dfsg/test/cases/mixin.blocks.jade000066400000000000000000000012451237002143700215650ustar00rootroot00000000000000 mixin form(method, action) form(method=method, action=action) - var csrf_token_from_somewhere = 'hey' input(type='hidden', name='_csrf', value=csrf_token_from_somewhere) block html body +form('GET', '/search') input(type='text', name='query', placeholder='Search') input(type='submit', value='Search') html body +form('POST', '/search') input(type='text', name='query', placeholder='Search') input(type='submit', value='Search') html body +form('POST', '/search') mixin bar() #bar block mixin foo() #foo +bar block +foo p one p two p three mixin baz #baz block +baz()= '123'node-jade-1.5.0+dfsg/test/cases/mixin.merge.html000066400000000000000000000021671237002143700214540ustar00rootroot00000000000000

    One

    Two

    Three

    Four

    One

    Two

    Three

    Four

    One

    Two

    Three

    Four

    One

    Two

    Three

    Four

    One

    Two

    Three

    Four

    One

    Two

    Three

    Four

    One

    Two

    Three

    Four

    One

    Two

    Three

    Four

    node-jade-1.5.0+dfsg/test/cases/mixin.merge.jade000066400000000000000000000005111237002143700214020ustar00rootroot00000000000000mixin foo p.bar&attributes(attributes) One p.baz.quux&attributes(attributes) Two p&attributes(attributes) Three p.bar&attributes(attributes)(class="baz") Four body +foo.hello +foo#world +foo.hello#world +foo.hello.world +foo(class="hello") +foo.hello(class="world") +foo +foo&attributes({class: "hello"})node-jade-1.5.0+dfsg/test/cases/mixins-unused.html000066400000000000000000000000151237002143700220300ustar00rootroot00000000000000node-jade-1.5.0+dfsg/test/cases/mixins-unused.jade000066400000000000000000000001121237002143700217650ustar00rootroot00000000000000mixin never-called .wtf This isn't something we ever want to output bodynode-jade-1.5.0+dfsg/test/cases/mixins.html000066400000000000000000000004671237002143700205420ustar00rootroot00000000000000

    Tobi

    This

    is regular, javascript

    • foo
    • bar
    • baz
    This is interpolated
    node-jade-1.5.0+dfsg/test/cases/mixins.jade000066400000000000000000000006361237002143700204770ustar00rootroot00000000000000mixin comment(title, str) .comment h2= title p.body= str mixin comment (title, str) .comment h2= title p.body= str #user h1 Tobi .comments +comment('This', (('is regular, javascript'))) mixin list ul li foo li bar li baz body mixin list() mixin foobar(str) div#interpolation= str + 'interpolated' - var suffix = "bar" +#{'foo' + suffix}('This is ') node-jade-1.5.0+dfsg/test/cases/namespaces.html000066400000000000000000000000771237002143700213470ustar00rootroot00000000000000Something node-jade-1.5.0+dfsg/test/cases/namespaces.jade000066400000000000000000000000501237002143700212750ustar00rootroot00000000000000fb:user:role Something foo(fb:foo='bar')node-jade-1.5.0+dfsg/test/cases/nesting.html000066400000000000000000000001651237002143700206750ustar00rootroot00000000000000
    • a
    • b
      • c
      • d
    • e
    node-jade-1.5.0+dfsg/test/cases/nesting.jade000066400000000000000000000000751237002143700206340ustar00rootroot00000000000000ul li a li b li ul li c li d li enode-jade-1.5.0+dfsg/test/cases/pre.html000066400000000000000000000000731237002143700200120ustar00rootroot00000000000000
    foo
    bar
    baz
    
    foo
    bar
    baz
    node-jade-1.5.0+dfsg/test/cases/pre.jade000066400000000000000000000000731237002143700177510ustar00rootroot00000000000000pre. foo bar baz pre code. foo bar baznode-jade-1.5.0+dfsg/test/cases/quotes.html000066400000000000000000000000311237002143700205360ustar00rootroot00000000000000

    "foo"

    'foo'

    node-jade-1.5.0+dfsg/test/cases/quotes.jade000066400000000000000000000000171237002143700205010ustar00rootroot00000000000000p "foo" p 'foo'node-jade-1.5.0+dfsg/test/cases/regression.784.html000066400000000000000000000000411237002143700217200ustar00rootroot00000000000000
    google.com
    node-jade-1.5.0+dfsg/test/cases/regression.784.jade000066400000000000000000000001341237002143700216620ustar00rootroot00000000000000- var url = 'http://www.google.com' .url #{url.replace('http://', '').replace(/^www\./, '')}node-jade-1.5.0+dfsg/test/cases/script.whitespace.html000066400000000000000000000000661237002143700226650ustar00rootroot00000000000000node-jade-1.5.0+dfsg/test/cases/script.whitespace.jade000066400000000000000000000000531237002143700226200ustar00rootroot00000000000000script. if (foo) { bar(); }node-jade-1.5.0+dfsg/test/cases/scripts.html000066400000000000000000000001721237002143700207130ustar00rootroot00000000000000
    node-jade-1.5.0+dfsg/test/cases/scripts.jade000066400000000000000000000001141237002143700206460ustar00rootroot00000000000000script. if (foo) { bar(); } script!= 'foo()' script foo() script divnode-jade-1.5.0+dfsg/test/cases/scripts.non-js.html000066400000000000000000000003551237002143700221210ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/scripts.non-js.jade000066400000000000000000000002611237002143700220540ustar00rootroot00000000000000script#user-template(type='text/template') #user h1 <%= user.name %> p <%= user.description %> script#user-template(type='text/template'). if (foo) { bar(); }node-jade-1.5.0+dfsg/test/cases/single-period.html000066400000000000000000000000161237002143700217620ustar00rootroot00000000000000.node-jade-1.5.0+dfsg/test/cases/single-period.jade000066400000000000000000000000061237002143700217200ustar00rootroot00000000000000span .node-jade-1.5.0+dfsg/test/cases/some-included.styl000066400000000000000000000000241237002143700217770ustar00rootroot00000000000000body padding 10px node-jade-1.5.0+dfsg/test/cases/some.md000066400000000000000000000000601237002143700176170ustar00rootroot00000000000000Just _some_ markdown **tests**. With new line. node-jade-1.5.0+dfsg/test/cases/some.styl000066400000000000000000000000301237002143700202070ustar00rootroot00000000000000@import "some-included" node-jade-1.5.0+dfsg/test/cases/source.html000066400000000000000000000002161237002143700205230ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/source.jade000066400000000000000000000001361237002143700204630ustar00rootroot00000000000000html audio(preload='auto', autobuffer, controls) source(src='foo') source(src='bar')node-jade-1.5.0+dfsg/test/cases/styles.html000066400000000000000000000001461237002143700205500ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/styles.jade000066400000000000000000000001021237002143700204770ustar00rootroot00000000000000html head style. body { padding: 50px; }node-jade-1.5.0+dfsg/test/cases/tag.interpolation.html000066400000000000000000000003241237002143700226640ustar00rootroot00000000000000

    value

    value

    here node-jade-1.5.0+dfsg/test/cases/tag.interpolation.jade000066400000000000000000000005671237002143700226340ustar00rootroot00000000000000 - var tag = 'p' - var foo = 'bar' #{tag} value #{tag}(foo='bar') value #{foo ? 'a' : 'li'}(something) here mixin item(icon) li if attributes.href a&attributes(attributes) img.icon(src=icon) block else span&attributes(attributes) img.icon(src=icon) block ul +item('contact') Contact +item(href='/contact') Contact node-jade-1.5.0+dfsg/test/cases/tags.self-closing.html000066400000000000000000000002041237002143700225420ustar00rootroot00000000000000 / / node-jade-1.5.0+dfsg/test/cases/tags.self-closing.jade000066400000000000000000000002701237002143700225040ustar00rootroot00000000000000 body foo foo(bar='baz') foo/ foo(bar='baz')/ foo / foo(bar='baz') / //- can have a single space after them img //- can have lots of white space after them img node-jade-1.5.0+dfsg/test/cases/template.html000066400000000000000000000003171237002143700210400ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/template.jade000066400000000000000000000002421237002143700207740ustar00rootroot00000000000000script(type='text/x-template') article h2 {{title}} p {{description}} script(type='text/x-template'). article h2 {{title}} p {{description}} node-jade-1.5.0+dfsg/test/cases/text-block.html000066400000000000000000000002051237002143700212750ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/text-block.jade000066400000000000000000000001611237002143700212350ustar00rootroot00000000000000 label Username: input(type='text', name='user[name]') label Password: input(type='text', name='user[pass]')node-jade-1.5.0+dfsg/test/cases/text.html000066400000000000000000000002471237002143700202130ustar00rootroot00000000000000

    foo bar baz

    foo bar baz

    foo
      bar
        baz
    .
    foo
      bar
        baz
    .
    node-jade-1.5.0+dfsg/test/cases/text.jade000066400000000000000000000002371237002143700201510ustar00rootroot00000000000000option(value='') -- (selected) -- p | foo | bar | baz p. foo bar baz pre | foo | bar | baz | . pre. foo bar baz .node-jade-1.5.0+dfsg/test/cases/utf8bom.html000066400000000000000000000000151237002143700206040ustar00rootroot00000000000000

    "foo"

    node-jade-1.5.0+dfsg/test/cases/utf8bom.jade000066400000000000000000000000131237002143700205410ustar00rootroot00000000000000p "foo" node-jade-1.5.0+dfsg/test/cases/vars.html000066400000000000000000000000361237002143700201760ustar00rootroot00000000000000node-jade-1.5.0+dfsg/test/cases/vars.jade000066400000000000000000000000741237002143700201370ustar00rootroot00000000000000- var foo = 'bar' - var list = [1,2,3] a(class=list, id=foo)node-jade-1.5.0+dfsg/test/cases/while.html000066400000000000000000000002011237002143700203250ustar00rootroot00000000000000
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    node-jade-1.5.0+dfsg/test/cases/while.jade000066400000000000000000000000641237002143700202730ustar00rootroot00000000000000- var x = 1; ul while x < 10 - x++; li= x node-jade-1.5.0+dfsg/test/cases/xml.html000066400000000000000000000001431237002143700200220ustar00rootroot00000000000000 http://google.comnode-jade-1.5.0+dfsg/test/cases/xml.jade000066400000000000000000000000761237002143700177660ustar00rootroot00000000000000doctype xml category(term='some term')/ link http://google.comnode-jade-1.5.0+dfsg/test/cases/yield-before-conditional-head.html000066400000000000000000000000631237002143700247710ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/yield-before-conditional-head.jade000066400000000000000000000001231237002143700247250ustar00rootroot00000000000000head script(src='/jquery.js') yield if false script(src='/jquery.ui.js') node-jade-1.5.0+dfsg/test/cases/yield-before-conditional.html000066400000000000000000000002611237002143700240720ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/yield-before-conditional.jade000066400000000000000000000001621237002143700240310ustar00rootroot00000000000000html body include yield-before-conditional-head script(src='/caustic.js') script(src='/app.js') node-jade-1.5.0+dfsg/test/cases/yield-head.html000066400000000000000000000001331237002143700212260ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/yield-head.jade000066400000000000000000000001061237002143700211650ustar00rootroot00000000000000head script(src='/jquery.js') yield script(src='/jquery.ui.js') node-jade-1.5.0+dfsg/test/cases/yield-title-head.html000066400000000000000000000001551237002143700223510ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/yield-title-head.jade000066400000000000000000000001201237002143700223000ustar00rootroot00000000000000head title yield script(src='/jquery.js') script(src='/jquery.ui.js') node-jade-1.5.0+dfsg/test/cases/yield-title.html000066400000000000000000000002531237002143700214510ustar00rootroot00000000000000 My Title node-jade-1.5.0+dfsg/test/cases/yield-title.jade000066400000000000000000000000711237002143700214060ustar00rootroot00000000000000html body include yield-title-head | My Titlenode-jade-1.5.0+dfsg/test/cases/yield.html000066400000000000000000000003351237002143700203330ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/cases/yield.jade000066400000000000000000000001371237002143700202720ustar00rootroot00000000000000html body include yield-head script(src='/caustic.js') script(src='/app.js') node-jade-1.5.0+dfsg/test/command-line.js000066400000000000000000000031331237002143700201410ustar00rootroot00000000000000'use strict'; var fs = require('fs'); var path = require('path'); var assert = require('assert'); var exec = require('child_process').exec; function run(args, callback) { exec('node ' + JSON.stringify(path.resolve(__dirname + '/../bin/jade.js')) + ' ' + args, { cwd: __dirname + '/temp' }, callback); } try { fs.mkdirSync(__dirname + '/temp'); } catch (ex) { if (ex.code !== 'EEXIST') { throw ex; } } describe('command line', function () { it('jade --no-debug --client --name myTemplate input.jade', function (done) { fs.writeFileSync(__dirname + '/temp/input.jade', '.foo bar'); fs.writeFileSync(__dirname + '/temp/input.js', 'throw new Error("output not written");'); run('--no-debug --client --name myTemplate input.jade', function (err) { if (err) return done(err); var template = Function('', fs.readFileSync(__dirname + '/temp/input.js', 'utf8') + ';return myTemplate;')(); assert(template() === '
    bar
    '); done(); }); }); it('jade --no-debug --client --name-after-file input-file.jade', function (done) { fs.writeFileSync(__dirname + '/temp/input-file.jade', '.foo bar'); fs.writeFileSync(__dirname + '/temp/input-file.js', 'throw new Error("output not written");'); run('--no-debug --client --name-after-file input-file.jade', function (err, stdout, stderr) { if (err) return done(err); var template = Function('', fs.readFileSync(__dirname + '/temp/input-file.js', 'utf8') + ';return inputFileTemplate;')(); assert(template() === '
    bar
    '); return done(); }); }); }); node-jade-1.5.0+dfsg/test/dependencies/000077500000000000000000000000001237002143700176665ustar00rootroot00000000000000node-jade-1.5.0+dfsg/test/dependencies/dependency1.jade000066400000000000000000000000231237002143700227050ustar00rootroot00000000000000strong dependency1 node-jade-1.5.0+dfsg/test/dependencies/dependency2.jade000066400000000000000000000000241237002143700227070ustar00rootroot00000000000000include dependency3 node-jade-1.5.0+dfsg/test/dependencies/dependency3.jade000066400000000000000000000000231237002143700227070ustar00rootroot00000000000000strong dependency3 node-jade-1.5.0+dfsg/test/dependencies/extends1.jade000066400000000000000000000000241237002143700222420ustar00rootroot00000000000000extends dependency1 node-jade-1.5.0+dfsg/test/dependencies/extends2.jade000066400000000000000000000000241237002143700222430ustar00rootroot00000000000000extends dependency2 node-jade-1.5.0+dfsg/test/dependencies/include1.jade000066400000000000000000000000241237002143700222130ustar00rootroot00000000000000include dependency1 node-jade-1.5.0+dfsg/test/dependencies/include2.jade000066400000000000000000000000241237002143700222140ustar00rootroot00000000000000include dependency2 node-jade-1.5.0+dfsg/test/deprecated.js000066400000000000000000000045121237002143700177000ustar00rootroot00000000000000'use strict'; var assert = require('assert'); var util = require('util'); var jade = require('../'); function deprecate(name, fn, regex) { it(name, function () { var consoleError = console.error; var consoleWarn = console.warn; var log = ''; console.warn = function (msg) { log += msg; }; console.error = function (msg) { log += msg; }; try { fn(); regex = regex || new RegExp(name + ' is deprecated and will be removed in v2.0.0'); assert(regex.test(log), 'Expected ' + JSON.stringify(log) + ' to match ' + util.inspect(regex)); } catch (ex) { console.error = consoleError; console.warn = consoleWarn; throw ex; } console.error = consoleError; console.warn = consoleWarn; }); } describe('deprecated functions', function () { deprecate('tag.clone', function () { var tag = new jade.nodes.Tag(); tag.clone(); }); deprecate('node.clone', function () { var code = new jade.nodes.Code('var x = 10'); code.clone(); }); deprecate('block.clone', function () { var block = new jade.nodes.Block(new jade.nodes.Code('var x = 10')); block.clone(); }); deprecate('block.replace', function () { var block = new jade.nodes.Block(new jade.nodes.Code('var x = 10')); block.replace({}); }); deprecate('attrs.removeAttribute', function () { var tag = new jade.nodes.Tag('a'); tag.setAttribute('foo', 'value'); tag.removeAttribute('href'); assert(!tag.getAttribute('href')); tag.setAttribute('href', 'value'); tag.removeAttribute('href'); assert(!tag.getAttribute('href')); }); deprecate('attrs.getAttribute', function () { var tag = new jade.nodes.Tag('a'); tag.setAttribute('href', 'value'); assert(tag.getAttribute('href') === 'value'); }); deprecate('jade.compile(str, {client: true})', function () { var fn = jade.compile('div', {client: true}); var fn = Function('jade', fn.toString() + '\nreturn template;')(jade.runtime); assert(fn() === '
    '); }, /The `client` option is deprecated/); }); describe('warnings that will become errors', function () { deprecate('block that is never actually used', function () { jade.renderFile(__dirname + '/fixtures/invalid-block-in-extends.jade'); }, /Warning\: Unexpected block .* on line.*of.*This warning will be an error in v2\.0\.0/); });node-jade-1.5.0+dfsg/test/error.reporting.js000066400000000000000000000213731237002143700207450ustar00rootroot00000000000000 /** * Module dependencies. */ var jade = require('../') , assert = require('assert') , fs = require('fs'); // Shortcut function getError(str, options){ try { jade.render(str, options); } catch (ex) { return ex; } throw new Error('Input was supposed to result in an error.'); } function getFileError(name, options){ try { jade.renderFile(name, options); } catch (ex) { return ex; } throw new Error('Input was supposed to result in an error.'); } describe('error reporting', function () { describe('compile time errors', function () { describe('with no filename', function () { it('includes detail of where the error was thrown', function () { var err = getError('foo(') assert(/Jade:1/.test(err.message)) assert(/foo\(/.test(err.message)) }); }); describe('with a filename', function () { it('includes detail of where the error was thrown including the filename', function () { var err = getError('foo(', {filename: 'test.jade'}) assert(/test\.jade:1/.test(err.message)) assert(/foo\(/.test(err.message)) }); }); describe('with a layout without block declaration (syntax)', function () { it('includes detail of where the error was thrown including the filename', function () { var err = getFileError(__dirname + '/fixtures/compile.with.layout.syntax.error.jade', {}) assert(/[\\\/]layout.syntax.error.jade:2/.test(err.message)) assert(/foo\(/.test(err.message)) }); }); describe('with a layout without block declaration (locals)', function () { it('includes detail of where the error was thrown including the filename', function () { var err = getFileError(__dirname + '/fixtures/compile.with.layout.locals.error.jade', {}) assert(/[\\\/]layout.locals.error.jade:2/.test(err.message)) assert(/undefined is not a function/.test(err.message)) }); }); describe('with a include (syntax)', function () { it('includes detail of where the error was thrown including the filename', function () { var err = getFileError(__dirname + '/fixtures/compile.with.include.syntax.error.jade', {}) assert(/[\\\/]include.syntax.error.jade:2/.test(err.message)) assert(/foo\(/.test(err.message)) }); }); describe('with a include (locals)', function () { it('includes detail of where the error was thrown including the filename', function () { var err = getFileError(__dirname + '/fixtures/compile.with.include.locals.error.jade', {}) assert(/[\\\/]include.locals.error.jade:2/.test(err.message)) assert(/foo\(/.test(err.message)) }); }); describe('with a layout (without block) with an include (syntax)', function () { it('includes detail of where the error was thrown including the filename', function () { var err = getFileError(__dirname + '/fixtures/compile.with.layout.with.include.syntax.error.jade', {}) assert(/[\\\/]include.syntax.error.jade:2/.test(err.message)) assert(/foo\(/.test(err.message)) }); }); describe('with a layout (without block) with an include (locals)', function () { it('includes detail of where the error was thrown including the filename', function () { var err = getFileError(__dirname + '/fixtures/compile.with.layout.with.include.locals.error.jade', {}) assert(/[\\\/]include.locals.error.jade:2/.test(err.message)) assert(/foo\(/.test(err.message)) }); }); describe('Unexpected character', function () { it('includes details of where the error was thrown', function () { var err = getError('ul?', {}); assert(err.message.indexOf('unexpected text ?') !== -1); }); }); describe('Include filtered', function () { it('includes details of where the error was thrown', function () { var err = getError('include:js()!', {}); assert(err.message.indexOf('expected space after include:filter but got "!"') !== -1); var err = getError('include:js ', {}); assert(err.message.indexOf('missing path for include:filter') !== -1); }); }); }); describe('runtime errors', function () { describe('with no filename and `compileDebug` left undefined', function () { it('just reports the line number', function () { var sentinel = new Error('sentinel'); var err = getError('-foo()', {foo: function () { throw sentinel; }}) assert(/on line 1/.test(err.message)) }); }); describe('with no filename and `compileDebug` set to `true`', function () { it('includes detail of where the error was thrown', function () { var sentinel = new Error('sentinel'); var err = getError('-foo()', {foo: function () { throw sentinel; }, compileDebug: true}) assert(/Jade:1/.test(err.message)) assert(/-foo\(\)/.test(err.message)) }); }); describe('with a filename that does not correspond to a real file and `compileDebug` left undefined', function () { it('just reports the line number', function () { var sentinel = new Error('sentinel'); var err = getError('-foo()', {foo: function () { throw sentinel; }, filename: 'fake.jade'}) assert(/on line 1/.test(err.message)) }); }); describe('with a filename that corresponds to a real file and `compileDebug` left undefined', function () { it('includes detail of where the error was thrown including the filename', function () { var sentinel = new Error('sentinel'); var path = __dirname + '/fixtures/runtime.error.jade' var err = getError(fs.readFileSync(path, 'utf8'), {foo: function () { throw sentinel; }, filename: path}) assert(/fixtures[\\\/]runtime\.error\.jade:1/.test(err.message)) assert(/-foo\(\)/.test(err.message)) }); }); describe('in a mixin', function () { it('includes detail of where the error was thrown including the filename', function () { var err = getFileError(__dirname + '/fixtures/runtime.with.mixin.error.jade', {}) assert(/mixin.error.jade:2/.test(err.message)) assert(/Cannot read property 'length' of null/.test(err.message)) }); }); describe('in a layout', function () { it('includes detail of where the error was thrown including the filename', function () { var err = getFileError(__dirname + '/fixtures/runtime.layout.error.jade', {}) assert(/layout.with.runtime.error.jade:3/.test(err.message)) assert(/Cannot read property 'length' of undefined/.test(err.message)) }); }); }); describe('deprecated features', function () { it('deprecates `!!!` in favour of `doctype`', function () { var err = getError('!!! 5', {filename: 'test.jade'}) assert(/test\.jade:1/.test(err.message)) assert(/`!!!` is deprecated, you must now use `doctype`/.test(err.message)) }); it('deprecates `doctype 5` in favour of `doctype html`', function () { var err = getError('doctype 5', {filename: 'test.jade'}) assert(/test\.jade:1/.test(err.message)) assert(/`doctype 5` is deprecated, you must now use `doctype html`/.test(err.message)) }); it('warns about element-with-multiple-attributes', function () { var consoleWarn = console.warn; var log = ''; console.warn = function (str) { log += str; }; var res = jade.renderFile(__dirname + '/fixtures/element-with-multiple-attributes.jade'); console.warn = consoleWarn; assert(/element-with-multiple-attributes.jade, line 1:/.test(log)); assert(/You should not have jade tags with multiple attributes/.test(log)); assert(res === '
    '); }); it('warns about missing space at the start of a line', function () { var consoleWarn = console.warn; var log = ''; console.warn = function (str) { log += str; }; var res = jade.render('%This line is plain text, but it should not be', {filename: 'foo.jade'}); console.warn = consoleWarn; assert(log === 'Warning: missing space before text for line 1 of jade file "foo.jade"'); assert(res === '%This line is plain text, but it should not be'); }); }); describe('if you throw something that isn\'t an error', function () { it('just rethrows without modification', function () { var err = getError('- throw "foo"'); assert(err === 'foo'); }); }); describe('import without a filename for a basedir', function () { it('throws an error', function () { var err = getError('include foo.jade'); assert(/the "filename" option is required to use/.test(err.message)); var err = getError('include /foo.jade'); assert(/the "basedir" option is required to use/.test(err.message)); }) }); }); node-jade-1.5.0+dfsg/test/examples.js000066400000000000000000000011341237002143700174130ustar00rootroot00000000000000'use strict'; var fs = require('fs'); var jade = require('../'); describe('examples', function () { it('none of them throw any errors', function () { var log = console.log; var err = console.error; console.log = function () {}; console.error = function () {}; try { fs.readdirSync(__dirname + '/../examples').forEach(function (example) { if (/\.js$/.test(example)) { require('../examples/' + example); } }); } catch (ex) { console.log = log; console.error = err; } console.log = log; console.error = err; }); });node-jade-1.5.0+dfsg/test/fixtures/000077500000000000000000000000001237002143700171115ustar00rootroot00000000000000node-jade-1.5.0+dfsg/test/fixtures/append-without-block/000077500000000000000000000000001237002143700231515ustar00rootroot00000000000000node-jade-1.5.0+dfsg/test/fixtures/append-without-block/app-layout.jade000066400000000000000000000000631237002143700260700ustar00rootroot00000000000000 extends layout append head script(src='app.js')node-jade-1.5.0+dfsg/test/fixtures/append-without-block/layout.jade000066400000000000000000000001571237002143700253160ustar00rootroot00000000000000 html block head script(src='vendor/jquery.js') script(src='vendor/caustic.js') body block bodynode-jade-1.5.0+dfsg/test/fixtures/append-without-block/page.jade000066400000000000000000000001171237002143700247110ustar00rootroot00000000000000 extends app-layout append head script(src='foo.js') script(src='bar.js') node-jade-1.5.0+dfsg/test/fixtures/append/000077500000000000000000000000001237002143700203605ustar00rootroot00000000000000node-jade-1.5.0+dfsg/test/fixtures/append/app-layout.jade000066400000000000000000000000711237002143700232760ustar00rootroot00000000000000 extends layout block append head script(src='app.js')node-jade-1.5.0+dfsg/test/fixtures/append/layout.jade000066400000000000000000000001571237002143700225250ustar00rootroot00000000000000 html block head script(src='vendor/jquery.js') script(src='vendor/caustic.js') body block bodynode-jade-1.5.0+dfsg/test/fixtures/append/page.html000066400000000000000000000003341237002143700221620ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/fixtures/append/page.jade000066400000000000000000000001251237002143700221170ustar00rootroot00000000000000 extends app-layout block append head script(src='foo.js') script(src='bar.js') node-jade-1.5.0+dfsg/test/fixtures/compile.with.include.locals.error.jade000066400000000000000000000000411237002143700263610ustar00rootroot00000000000000include include.locals.error.jadenode-jade-1.5.0+dfsg/test/fixtures/compile.with.include.syntax.error.jade000066400000000000000000000000411237002143700264320ustar00rootroot00000000000000include include.syntax.error.jadenode-jade-1.5.0+dfsg/test/fixtures/compile.with.layout.locals.error.jade000066400000000000000000000000401237002143700262520ustar00rootroot00000000000000extends layout.locals.error.jadenode-jade-1.5.0+dfsg/test/fixtures/compile.with.layout.syntax.error.jade000066400000000000000000000000401237002143700263230ustar00rootroot00000000000000extends layout.syntax.error.jadenode-jade-1.5.0+dfsg/test/fixtures/compile.with.layout.with.include.locals.error.jade000066400000000000000000000000561237002143700306550ustar00rootroot00000000000000extends compile.with.include.locals.error.jadenode-jade-1.5.0+dfsg/test/fixtures/compile.with.layout.with.include.syntax.error.jade000066400000000000000000000000561237002143700307260ustar00rootroot00000000000000extends compile.with.include.syntax.error.jadenode-jade-1.5.0+dfsg/test/fixtures/element-with-multiple-attributes.jade000066400000000000000000000000321237002143700263500ustar00rootroot00000000000000div(attr='val')(foo='bar')node-jade-1.5.0+dfsg/test/fixtures/include.locals.error.jade000066400000000000000000000000101237002143700237540ustar00rootroot00000000000000 = foo()node-jade-1.5.0+dfsg/test/fixtures/include.syntax.error.jade000066400000000000000000000000071237002143700240330ustar00rootroot00000000000000 = foo(node-jade-1.5.0+dfsg/test/fixtures/invalid-block-in-extends.jade000066400000000000000000000001431237002143700245260ustar00rootroot00000000000000extends ./layout.jade block title title My Article block contents // oops, that's not a blocknode-jade-1.5.0+dfsg/test/fixtures/layout.jade000066400000000000000000000000761237002143700212560ustar00rootroot00000000000000doctype html html head block title body block bodynode-jade-1.5.0+dfsg/test/fixtures/layout.locals.error.jade000066400000000000000000000000101237002143700236460ustar00rootroot00000000000000 = foo()node-jade-1.5.0+dfsg/test/fixtures/layout.syntax.error.jade000066400000000000000000000000071237002143700237250ustar00rootroot00000000000000 = foo(node-jade-1.5.0+dfsg/test/fixtures/layout.with.runtime.error.jade000066400000000000000000000000601237002143700250330ustar00rootroot00000000000000html body = foo.length block content node-jade-1.5.0+dfsg/test/fixtures/mixin-include.jade000066400000000000000000000000441237002143700225010ustar00rootroot00000000000000mixin bang +foo mixin foo p barnode-jade-1.5.0+dfsg/test/fixtures/mixin.error.jade000066400000000000000000000000531237002143700222100ustar00rootroot00000000000000mixin mixin-with-error(foo) - foo.length node-jade-1.5.0+dfsg/test/fixtures/multi-append-prepend-block/000077500000000000000000000000001237002143700242335ustar00rootroot00000000000000node-jade-1.5.0+dfsg/test/fixtures/multi-append-prepend-block/redefine.jade000066400000000000000000000000711237002143700266370ustar00rootroot00000000000000extends root block content .content | Defined contentnode-jade-1.5.0+dfsg/test/fixtures/multi-append-prepend-block/root.jade000066400000000000000000000001031237002143700260350ustar00rootroot00000000000000block content | default content block head script(src='/app.js')node-jade-1.5.0+dfsg/test/fixtures/perf.jade000066400000000000000000000026241237002143700206760ustar00rootroot00000000000000.data ol.sortable#contents each item in report if (!item.parent) div li.chapter(data-ref= item.id) a(href='/admin/report/detail/' + item.id) = item.name - var chp = item.id ol.sortable each item in report if (item.parent === chp && item.type === 'section') div li.section(data-ref= item.id) a(href='/admin/report/detail/' + item.id) = item.name - var sec = item.id ol.sortable each item in report if (item.parent === sec && item.type === 'page') div li.page(data-ref= item.id) a(href='/admin/report/detail/' + item.id) = item.name - var page = item.id ol.sortable each item in report if (item.parent === page && item.type === 'subpage') div li.subpage(data-ref= item.id) a(href='/admin/report/detail/' + item.id) = item.namenode-jade-1.5.0+dfsg/test/fixtures/prepend-without-block/000077500000000000000000000000001237002143700233375ustar00rootroot00000000000000node-jade-1.5.0+dfsg/test/fixtures/prepend-without-block/app-layout.jade000066400000000000000000000000641237002143700262570ustar00rootroot00000000000000 extends layout prepend head script(src='app.js')node-jade-1.5.0+dfsg/test/fixtures/prepend-without-block/layout.jade000066400000000000000000000001571237002143700255040ustar00rootroot00000000000000 html block head script(src='vendor/jquery.js') script(src='vendor/caustic.js') body block bodynode-jade-1.5.0+dfsg/test/fixtures/prepend-without-block/page.html000066400000000000000000000003341237002143700251410ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/fixtures/prepend-without-block/page.jade000066400000000000000000000001201237002143700250710ustar00rootroot00000000000000 extends app-layout prepend head script(src='foo.js') script(src='bar.js') node-jade-1.5.0+dfsg/test/fixtures/prepend/000077500000000000000000000000001237002143700205465ustar00rootroot00000000000000node-jade-1.5.0+dfsg/test/fixtures/prepend/app-layout.jade000066400000000000000000000000721237002143700234650ustar00rootroot00000000000000 extends layout block prepend head script(src='app.js')node-jade-1.5.0+dfsg/test/fixtures/prepend/layout.jade000066400000000000000000000001571237002143700227130ustar00rootroot00000000000000 html block head script(src='vendor/jquery.js') script(src='vendor/caustic.js') body block bodynode-jade-1.5.0+dfsg/test/fixtures/prepend/page.html000066400000000000000000000003341237002143700223500ustar00rootroot00000000000000 node-jade-1.5.0+dfsg/test/fixtures/prepend/page.jade000066400000000000000000000001261237002143700223060ustar00rootroot00000000000000 extends app-layout block prepend head script(src='foo.js') script(src='bar.js') node-jade-1.5.0+dfsg/test/fixtures/runtime.error.jade000066400000000000000000000000061237002143700225450ustar00rootroot00000000000000-foo()node-jade-1.5.0+dfsg/test/fixtures/runtime.layout.error.jade000066400000000000000000000001061237002143700240620ustar00rootroot00000000000000extends layout.with.runtime.error.jade block content | some content node-jade-1.5.0+dfsg/test/fixtures/runtime.with.mixin.error.jade000066400000000000000000000000671237002143700246510ustar00rootroot00000000000000include mixin.error.jade mixin mixin-with-error(null) node-jade-1.5.0+dfsg/test/fixtures/scripts.jade000066400000000000000000000000621237002143700214230ustar00rootroot00000000000000script(src='/jquery.js') script(src='/caustic.js')node-jade-1.5.0+dfsg/test/jade.test.js000066400000000000000000001137301237002143700174640ustar00rootroot00000000000000'use strict'; var assert = require('assert'); var fs = require('fs'); var path = require('path'); var jade = require('../'); var perfTest = fs.readFileSync(__dirname + '/fixtures/perf.jade', 'utf8') describe('jade', function(){ describe('.properties', function(){ it('should have exports', function(){ assert.equal('object', typeof jade.selfClosing, 'exports.selfClosing missing'); assert.equal('object', typeof jade.doctypes, 'exports.doctypes missing'); assert.equal('function', typeof jade.filters, 'exports.filters missing'); assert.equal('object', typeof jade.utils, 'exports.utils missing'); assert.equal('function', typeof jade.Compiler, 'exports.Compiler missing'); }); }); describe('.compile()', function(){ it('should support doctypes', function(){ assert.equal('', jade.render('doctype xml')); assert.equal('', jade.render('doctype html')); assert.equal('', jade.render('doctype foo bar baz')); assert.equal('', jade.render('doctype html')); assert.equal('', jade.render('doctype', { doctype:'html' })); assert.equal('', jade.render('doctype html', { doctype:'xml' })); assert.equal('', jade.render('html')); assert.equal('', jade.render('html', { doctype:'html' })); assert.equal('', jade.render('doctype html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN')); }); it('should support Buffers', function(){ assert.equal('

    foo

    ', jade.render(new Buffer('p foo'))); }); it('should support line endings', function(){ var src = [ 'p', 'div', 'img' ]; var html = [ '

    ', '
    ', '' ].join(''); assert.equal(html, jade.render(src.join('\n'))); assert.equal(html, jade.render(src.join('\r'))); assert.equal(html, jade.render(src.join('\r\n'))); html = [ '

    ', '
    ', '' ].join(''); assert.equal(html, jade.render(src.join('\n'), { doctype:'html' })); assert.equal(html, jade.render(src.join('\r'), { doctype:'html' })); assert.equal(html, jade.render(src.join('\r\n'), { doctype:'html' })); }); it('should support single quotes', function(){ assert.equal("

    'foo'

    ", jade.render("p 'foo'")); assert.equal("

    'foo'

    ", jade.render("p\n | 'foo'")); assert.equal('', jade.render("- var path = 'foo';\na(href='/' + path)")); }); it('should support block-expansion', function(){ assert.equal("
  • foo
  • bar
  • baz
  • ", jade.render("li: a foo\nli: a bar\nli: a baz")); assert.equal("
  • foo
  • bar
  • baz
  • ", jade.render("li.first: a foo\nli: a bar\nli: a baz")); assert.equal('
    baz
    ', jade.render(".foo: .bar baz")); }); it('should support tags', function(){ var str = [ 'p', 'div', 'img' ].join('\n'); var html = [ '

    ', '
    ', '' ].join(''); assert.equal(html, jade.render(str), 'Test basic tags'); assert.equal('', jade.render('fb:foo-bar'), 'Test hyphens'); assert.equal('
    ', jade.render('div.something'), 'Test classes'); assert.equal('
    ', jade.render('div#something'), 'Test ids'); assert.equal('
    ', jade.render('.something'), 'Test stand-alone classes'); assert.equal('
    ', jade.render('#something'), 'Test stand-alone ids'); assert.equal('
    ', jade.render('#foo.bar')); assert.equal('
    ', jade.render('.bar#foo')); assert.equal('
    ', jade.render('div#foo(class="bar")')); assert.equal('
    ', jade.render('div(class="bar")#foo')); assert.equal('
    ', jade.render('div(id="bar").foo')); assert.equal('
    ', jade.render('div.foo.bar.baz')); assert.equal('
    ', jade.render('div(class="foo").bar.baz')); assert.equal('
    ', jade.render('div.foo(class="bar").baz')); assert.equal('
    ', jade.render('div.foo.bar(class="baz")')); assert.equal('
    ', jade.render('div.a-b2')); assert.equal('
    ', jade.render('div.a_b2')); assert.equal('', jade.render('fb:user')); assert.equal('', jade.render('fb:user:role')); assert.equal('', jade.render('colgroup\n col.test')); }); it('should support nested tags', function(){ var str = [ 'ul', ' li a', ' li b', ' li', ' ul', ' li c', ' li d', ' li e', ].join('\n'); var html = [ '
      ', '
    • a
    • ', '
    • b
    • ', '
      • c
      • d
    • ', '
    • e
    • ', '
    ' ].join(''); assert.equal(html, jade.render(str)); var str = [ 'a(href="#")', ' | foo ', ' | bar ', ' | baz' ].join('\n'); assert.equal('foo \nbar \nbaz', jade.render(str)); var str = [ 'ul', ' li one', ' ul', ' | two', ' li three' ].join('\n'); var html = [ '
      ', '
    • one
    • ', '
        two', '
      • three
      • ', '
      ', '
    ' ].join(''); assert.equal(html, jade.render(str)); }); it('should support variable length newlines', function(){ var str = [ 'ul', ' li a', ' ', ' li b', ' ', ' ', ' li', ' ul', ' li c', '', ' li d', ' li e', ].join('\n'); var html = [ '
      ', '
    • a
    • ', '
    • b
    • ', '
      • c
      • d
    • ', '
    • e
    • ', '
    ' ].join(''); assert.equal(html, jade.render(str)); }); it('should support tab conversion', function(){ var str = [ 'ul', '\tli a', '\t', '\tli b', '\t\t', '\t\t\t\t\t\t', '\tli', '\t\tul', '\t\t\tli c', '', '\t\t\tli d', '\tli e', ].join('\n'); var html = [ '
      ', '
    • a
    • ', '
    • b
    • ', '
      • c
      • d
    • ', '
    • e
    • ', '
    ' ].join(''); assert.equal(html, jade.render(str)); }); it('should support newlines', function(){ var str = [ 'ul', ' li a', ' ', ' ', '', ' ', ' li b', ' li', ' ', ' ', ' ', ' ul', ' ', ' li c', ' li d', ' li e', ].join('\n'); var html = [ '
      ', '
    • a
    • ', '
    • b
    • ', '
      • c
      • d
    • ', '
    • e
    • ', '
    ' ].join(''); assert.equal(html, jade.render(str)); var str = [ 'html', ' ', ' head', ' != "test"', ' ', ' ', ' ', ' body' ].join('\n'); var html = [ '', '', 'test', '', '', '' ].join(''); assert.equal(html, jade.render(str)); assert.equal('something', jade.render('foo\n= "something"\nbar')); assert.equal('somethingelse', jade.render('foo\n= "something"\nbar\n= "else"')); }); it('should support text', function(){ assert.equal('foo\nbar\nbaz', jade.render('| foo\n| bar\n| baz')); assert.equal('foo \nbar \nbaz', jade.render('| foo \n| bar \n| baz')); assert.equal('(hey)', jade.render('| (hey)')); assert.equal('some random text', jade.render('| some random text')); assert.equal(' foo', jade.render('| foo')); assert.equal(' foo ', jade.render('| foo ')); assert.equal(' foo \n bar ', jade.render('| foo \n| bar ')); }); it('should support pipe-less text', function(){ assert.equal('
    ', jade.render('pre\n code\n foo\n\n bar')); assert.equal('

    foo\n\nbar

    ', jade.render('p.\n foo\n\n bar')); assert.equal('

    foo\n\n\n\nbar

    ', jade.render('p.\n foo\n\n\n\n bar')); assert.equal('

    foo\n bar\nfoo

    ', jade.render('p.\n foo\n bar\n foo')); assert.equal('', jade.render('script.\n s.parentNode.insertBefore(g,s)\n')); assert.equal('', jade.render('script.\n s.parentNode.insertBefore(g,s)')); }); it('should support tag text', function(){ assert.equal('

    some random text

    ', jade.render('p some random text')); assert.equal('

    clickGoogle.

    ', jade.render('p\n | click\n a Google\n | .')); assert.equal('

    (parens)

    ', jade.render('p (parens)')); assert.equal('

    (parens)

    ', jade.render('p(foo="bar") (parens)')); assert.equal('', jade.render('option(value="") -- (optional) foo --')); }); it('should support tag text block', function(){ assert.equal('

    foo \nbar \nbaz

    ', jade.render('p\n | foo \n | bar \n | baz')); assert.equal('', jade.render('label\n | Password:\n input')); assert.equal('', jade.render('label Password:\n input')); }); it('should support tag text interpolation', function(){ assert.equal('yo, jade is cool', jade.render('| yo, #{name} is cool\n', { name: 'jade' })); assert.equal('

    yo, jade is cool

    ', jade.render('p yo, #{name} is cool', { name: 'jade' })); assert.equal('yo, jade is cool', jade.render('| yo, #{name || "jade"} is cool', { name: null })); assert.equal('yo, \'jade\' is cool', jade.render('| yo, #{name || "\'jade\'"} is cool', { name: null })); assert.equal('foo <script> bar', jade.render('| foo #{code} bar', { code: '', '', '' ].join(''); assert.equal(html, jade.render(str)); }); it('should support comments', function(){ // Regular var str = [ '//foo', 'p bar' ].join('\n'); var html = [ '', '

    bar

    ' ].join(''); assert.equal(html, jade.render(str)); // Between tags var str = [ 'p foo', '// bar ', 'p baz' ].join('\n'); var html = [ '

    foo

    ', '', '

    baz

    ' ].join(''); assert.equal(html, jade.render(str)); // Quotes var str = "", js = "// script(src: '/js/validate.js') "; assert.equal(str, jade.render(js)); }); it('should support unbuffered comments', function(){ var str = [ '//- foo', 'p bar' ].join('\n'); var html = [ '

    bar

    ' ].join(''); assert.equal(html, jade.render(str)); var str = [ 'p foo', '//- bar ', 'p baz' ].join('\n'); var html = [ '

    foo

    ', '

    baz

    ' ].join(''); assert.equal(html, jade.render(str)); }); it('should support literal html', function(){ assert.equal('', jade.render('')); }); it('should support code', function(){ assert.equal('test', jade.render('!= "test"')); assert.equal('test', jade.render('= "test"')); assert.equal('test', jade.render('- var foo = "test"\n=foo')); assert.equal('footestbar', jade.render('- var foo = "test"\n| foo\nem= foo\n| bar')); assert.equal('test

    something

    ', jade.render('!= "test"\nh2 something')); var str = [ '- var foo = "' , jade.render(str, { filename: __dirname + '/jade.test.js' })); }); }); describe('.render()', function(){ it('should support .jade.render(str, fn)', function(){ jade.render('p foo bar', function(err, str){ assert.ok(!err); assert.equal('

    foo bar

    ', str); }); }); it('should support .jade.render(str, options, fn)', function(){ jade.render('p #{foo}', { foo: 'bar' }, function(err, str){ assert.ok(!err); assert.equal('

    bar

    ', str); }); }); it('should support .jade.render(str, options, fn) cache', function(){ jade.render('p bar', { cache: true }, function(err, str){ assert.ok(/the "filename" option is required for caching/.test(err.message)); }); jade.render('p foo bar', { cache: true, filename: 'test' }, function(err, str){ assert.ok(!err); assert.equal('

    foo bar

    ', str); }); }); it('should support .compile()', function(){ var fn = jade.compile('p foo'); assert.equal('

    foo

    ', fn()); }); it('should support .compile() locals', function(){ var fn = jade.compile('p= foo'); assert.equal('

    bar

    ', fn({ foo: 'bar' })); }); it('should support .compile() no debug', function(){ var fn = jade.compile('p foo\np #{bar}', {compileDebug: false}); assert.equal('

    foo

    baz

    ', fn({bar: 'baz'})); }); it('should support .compile() no debug and global helpers', function(){ var fn = jade.compile('p foo\np #{bar}', {compileDebug: false, helpers: 'global'}); assert.equal('

    foo

    baz

    ', fn({bar: 'baz'})); }); it('should be reasonably fast', function(){ jade.compile(perfTest, {}) }); it('allows trailing space (see #1586)', function () { var res = jade.render('ul \n li An Item'); assert.equal('
    • An Item
    ', res); }); }); describe('.renderFile()', function () { it('will synchronously return a string', function () { var expected = fs.readFileSync(__dirname + '/cases/basic.html', 'utf8').replace(/\s/g, ''); var actual = jade.renderFile(__dirname + '/cases/basic.jade', {name: 'foo'}).replace(/\s/g, ''); assert(actual === expected); }); it('when given a callback, it calls that rather than returning', function (done) { var expected = fs.readFileSync(__dirname + '/cases/basic.html', 'utf8').replace(/\s/g, ''); jade.renderFile(__dirname + '/cases/basic.jade', {name: 'foo'}, function (err, actual) { if (err) return done(err); assert(actual.replace(/\s/g, '') === expected); done(); }); }); it('when given a callback, it calls that rather than returning even if there are no options', function (done) { var expected = fs.readFileSync(__dirname + '/cases/basic.html', 'utf8').replace(/\s/g, ''); jade.renderFile(__dirname + '/cases/basic.jade', function (err, actual) { if (err) return done(err); assert(actual.replace(/\s/g, '') === expected); done(); }); }); it('when given a callback, it calls that with any errors', function (done) { jade.renderFile(__dirname + '/fixtures/runtime.error.jade', function (err, actual) { assert.ok(err); done(); }); }); }); describe('.compileFileClient(path, options)', function () { it('returns a string form of a function called `template`', function () { var src = jade.compileFileClient(__dirname + '/cases/basic.jade'); var expected = fs.readFileSync(__dirname + '/cases/basic.html', 'utf8').replace(/\s/g, ''); var fn = Function('jade', src + '\nreturn template;')(jade.runtime); var actual = fn({name: 'foo'}).replace(/\s/g, ''); assert(actual === expected); }); it('accepts the `name` option to rename the resulting function', function () { var src = jade.compileFileClient(__dirname + '/cases/basic.jade', {name: 'myTemplateName'}); var expected = fs.readFileSync(__dirname + '/cases/basic.html', 'utf8').replace(/\s/g, ''); var fn = Function('jade', src + '\nreturn myTemplateName;')(jade.runtime); var actual = fn({name: 'foo'}).replace(/\s/g, ''); assert(actual === expected); }); }); describe('.runtime', function () { describe('.merge', function () { it('merges two attribute objects, giving precedensce to the second object', function () { assert.deepEqual(jade.runtime.merge({}, {'class': ['foo', 'bar'], 'foo': 'bar'}), {'class': ['foo', 'bar'], 'foo': 'bar'}); assert.deepEqual(jade.runtime.merge({'class': ['foo'], 'foo': 'baz'}, {'class': ['bar'], 'foo': 'bar'}), {'class': ['foo', 'bar'], 'foo': 'bar'}); assert.deepEqual(jade.runtime.merge({'class': ['foo', 'bar'], 'foo': 'bar'}, {}), {'class': ['foo', 'bar'], 'foo': 'bar'}); }); }); describe('.attrs', function () { it('Renders the given attributes object', function () { assert.equal(jade.runtime.attrs({}), ''); assert.equal(jade.runtime.attrs({'class': []}), ''); assert.equal(jade.runtime.attrs({'class': ['foo']}), ' class="foo"'); assert.equal(jade.runtime.attrs({'class': ['foo'], 'id': 'bar'}), ' class="foo" id="bar"'); }); }); }); describe('filter indentation', function () { it('is maintained', function () { jade.filters.indents = function(str){ return str.split(/\n/).map(function (line) { return line.match(/^ */)[0].length; }).join(","); }; var indents = [ ':indents', ' x', ' x', ' x', ' x', ' x', ' x', ' x', ' x', ' x', ' x', ' x', ' x', ' x', ' x', ' x' ].join('\n'); assert.equal(jade.render(indents), '0,1,2,3,0,4,4,3,3,4,2,0,2,0,1'); }); }); describe('.compile().dependencies', function() { it('should list the filename of the template referenced by extends', function(){ var filename = __dirname + '/dependencies/extends1.jade'; var str = fs.readFileSync(filename, 'utf8'); var info = jade.compile(str, {filename: filename}); assert.deepEqual([ path.resolve(__dirname + '/dependencies/dependency1.jade') ], info.dependencies); }); it('should list the filename of the template referenced by an include', function() { var filename = __dirname + '/dependencies/include1.jade'; var str = fs.readFileSync(filename, 'utf8'); var info = jade.compile(str, {filename: filename}); assert.deepEqual([ path.resolve(__dirname + '/dependencies/dependency1.jade') ], info.dependencies); }); it('should list the dependencies of extends dependencies', function() { var filename = __dirname + '/dependencies/extends2.jade'; var str = fs.readFileSync(filename, 'utf8'); var info = jade.compile(str, {filename: filename}); assert.deepEqual([ path.resolve(__dirname + '/dependencies/dependency2.jade'), path.resolve(__dirname + '/dependencies/dependency3.jade') ], info.dependencies); }); it('should list the dependencies of include dependencies', function() { var filename = __dirname + '/dependencies/include2.jade'; var str = fs.readFileSync(filename, 'utf8'); var info = jade.compile(str, {filename: filename}); assert.deepEqual([ path.resolve(__dirname + '/dependencies/dependency2.jade'), path.resolve(__dirname + '/dependencies/dependency3.jade') ],info.dependencies); }); }); }); node-jade-1.5.0+dfsg/test/mocha.opts000066400000000000000000000000211237002143700172270ustar00rootroot00000000000000--require should node-jade-1.5.0+dfsg/test/run.js000066400000000000000000000073671237002143700164170ustar00rootroot00000000000000 /** * Module dependencies. */ var fs = require('fs'); var assert = require('assert'); var jade = require('../'); var uglify = require('uglify-js'); jade.filters['custom-filter'] = function (str, options) { assert(str === 'foo bar'); assert(options.foo === 'bar'); return 'bar baz'; }; // test cases var cases = fs.readdirSync('test/cases').filter(function(file){ return ~file.indexOf('.jade'); }).map(function(file){ return file.replace('.jade', ''); }); try { fs.mkdirSync(__dirname + '/output'); } catch (ex) { if (ex.code !== 'EEXIST') { throw ex; } } var mixinsUnusedTestRan = false; cases.forEach(function(test){ var name = test.replace(/[-.]/g, ' '); it(name, function(){ var path = 'test/cases/' + test + '.jade'; var str = fs.readFileSync(path, 'utf8'); var html = fs.readFileSync('test/cases/' + test + '.html', 'utf8').trim().replace(/\r/g, ''); var fn = jade.compile(str, { filename: path, pretty: true, basedir: 'test/cases' }); var actual = fn({ title: 'Jade' }); fs.writeFileSync(__dirname + '/output/' + test + '.html', actual); var clientCode = uglify.minify(jade.compileClient(str, { filename: path, pretty: true, compileDebug: false, basedir: 'test/cases' }), {output: {beautify: true}, mangle: false, compress: false, fromString: true}).code; var clientCodeDebug = uglify.minify(jade.compileClient(str, { filename: path, pretty: true, compileDebug: true, basedir: 'test/cases' }), {output: {beautify: true}, mangle: false, compress: false, fromString: true}).code; fs.writeFileSync(__dirname + '/output/' + test + '.js', uglify.minify(jade.compileClient(str, { filename: path, pretty: false, compileDebug: false, basedir: 'test/cases' }), {output: {beautify: true}, mangle: false, compress: false, fromString: true}).code); if (/filter/.test(test)) { actual = actual.replace(/\n| /g, ''); html = html.replace(/\n| /g, ''); } if (/mixins-unused/.test(test)) { mixinsUnusedTestRan = true; assert(/never-called/.test(str), 'never-called is in the jade file for mixins-unused'); assert(!/never-called/.test(clientCode), 'never-called should be removed from the code'); } JSON.stringify(actual.trim()).should.equal(JSON.stringify(html)); actual = Function('jade', clientCode + '\nreturn template;')(jade.runtime)({ title: 'Jade' }); if (/filter/.test(test)) { actual = actual.replace(/\n| /g, ''); } JSON.stringify(actual.trim()).should.equal(JSON.stringify(html)); actual = Function('jade', clientCodeDebug + '\nreturn template;')(jade.runtime)({ title: 'Jade' }); if (/filter/.test(test)) { actual = actual.replace(/\n| /g, ''); } JSON.stringify(actual.trim()).should.equal(JSON.stringify(html)); }) }); after(function () { assert(mixinsUnusedTestRan, 'mixins-unused test should run'); }) // test cases var anti = fs.readdirSync('test/anti-cases').filter(function(file){ return ~file.indexOf('.jade'); }).map(function(file){ return file.replace('.jade', ''); }); describe('certain syntax is not allowed and will throw a compile time error', function () { anti.forEach(function(test){ var name = test.replace(/[-.]/g, ' '); it(name, function(){ var path = 'test/anti-cases/' + test + '.jade'; var str = fs.readFileSync(path, 'utf8'); try { var fn = jade.compile(str, { filename: path, pretty: true, basedir: 'test/anti-cases' }); } catch (ex) { ex.should.be.an.instanceof(Error); ex.message.replace(/\\/g, '/').should.startWith(path); ex.message.replace(/\\/g, '/').should.match(/:\d+$/m); return; } throw new Error(test + ' should have thrown an error'); }) }); });node-jade-1.5.0+dfsg/test/unit.js000066400000000000000000000023221237002143700165540ustar00rootroot00000000000000 var runtime = require('../lib/runtime') , merge = runtime.merge; describe('merge(a, b, escaped)', function(){ it('should merge classes into strings', function(){ merge({ foo: 'bar' }, { bar: 'baz' }) .should.eql({ foo: 'bar', bar: 'baz' }); merge({ class: [] }, {}) .should.eql({ class: [] }); merge({ class: [] }, { class: [] }) .should.eql({ class: [] }); merge({ class: [] }, { class: ['foo'] }) .should.eql({ class: ['foo'] }); merge({ class: ['foo'] }, {}) .should.eql({ class: ['foo'] }); merge({ class: ['foo'] }, { class: ['bar'] }) .should.eql({ class: ['foo','bar'] }); merge({ class: ['foo', 'raz'] }, { class: ['bar', 'baz'] }) .should.eql({ class: ['foo', 'raz', 'bar', 'baz'] }); merge({ class: 'foo' }, { class: 'bar' }) .should.eql({ class: ['foo', 'bar'] }); merge({ class: 'foo' }, { class: ['bar', 'baz'] }) .should.eql({ class: ['foo', 'bar', 'baz'] }); merge({ class: ['foo', 'bar'] }, { class: 'baz' }) .should.eql({ class: ['foo', 'bar', 'baz'] }); merge({ class: ['foo', null, 'bar'] }, { class: [undefined, null, 0, 'baz'] }) .should.eql({ class: ['foo', 'bar', 0, 'baz'] }); }) })