pug
Advanced tools
Comparing version 0.1.0 to 2.0.0-alpha1
@@ -6,3 +6,3 @@ 'use strict'; | ||
console.log('This module can be used during development\n' + | ||
'to link the jade modules to your local development\n' + | ||
'to link the pug modules to your local development\n' + | ||
'copies rather than the versions downloaded from npm'); | ||
@@ -9,0 +9,0 @@ |
@@ -6,3 +6,3 @@ 1.11.0 / 2015-06-12 | ||
* Improved runtime performance of mixins significantly ([Andreas Lubbe](https://github.com/alubbe)) | ||
* Improved runtime performance of jade's string escaping ([Andreas Lubbe](https://github.com/alubbe)) and ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) | ||
* Improved runtime performance of pug's string escaping ([Andreas Lubbe](https://github.com/alubbe)) and ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) | ||
* Better line number counting for pipeless text ([@alephyud](https://github.com/alephyud)) | ||
@@ -147,3 +147,3 @@ | ||
* Use variables instead of properties of jade, improving performance and reliability with nested templates ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) | ||
* Use variables instead of properties of pug, 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)) | ||
@@ -264,3 +264,3 @@ * Lazily add mixins ([@ForbesLindesay](http://www.forbeslindesay.co.uk/)) | ||
* remove `jade.version` and fix `jade --version` | ||
* remove `pug.version` and fix `pug --version` | ||
* add file name and line number to deprecation warnings | ||
@@ -408,3 +408,3 @@ * use constantinople for better constant detection | ||
* Added tag interpolation. Closes #657 | ||
* Allow the compiled client to use it's own jade util functions [3rd-Eden] | ||
* Allow the compiled client to use it's own pug util functions [3rd-Eden] | ||
* Fixed `attrs()` escape bug [caseywebdev] | ||
@@ -450,3 +450,3 @@ | ||
* Fixed #1070, reverted mixin function statements | ||
* Fixed jade.1 typo | ||
* Fixed pug.1 typo | ||
@@ -462,6 +462,6 @@ 0.22.1 / 2012-04-04 | ||
* 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) | ||
* Added pug manpage (`man pug` after installation for docs) | ||
* Added `-D, --no-debug` to pug(1) | ||
* Added `-p, --pretty` to pug(1) | ||
* Added `-c, --client` option to pug(1) | ||
* Fixed `-o { client: true }` with stdin | ||
@@ -498,3 +498,3 @@ * Fixed: skip blank lines in lexer (unless within pipeless text). Closes #399 | ||
* Added `yield` for block `include`s | ||
* Changed: replaced internal `__` var with `__jade` [chrisleishman] | ||
* Changed: replaced internal `__` var with `__pug` [chrisleishman] | ||
* Fixed two globals. Closes #433 | ||
@@ -506,3 +506,3 @@ | ||
* Added block `append` / `prepend` support. Closes #355 | ||
* Added link in readme to jade-mode for Emacs | ||
* Added link in readme to pug-mode for Emacs | ||
* Added link to python implementation | ||
@@ -518,3 +518,3 @@ | ||
* jade.renderFile() is back! (for express 3.x) | ||
* pug.renderFile() is back! (for express 3.x) | ||
* Fixed `Object.keys()` failover bug | ||
@@ -534,3 +534,3 @@ | ||
* Fixed parens in mixin args. Closes #380 | ||
* Fixed: include files with a .jade extension as jade files | ||
* Fixed: include files with a .pug extension as pug files | ||
@@ -555,9 +555,9 @@ 0.16.2 / 2011-09-30 | ||
* Added 'uglifyjs' as an explicit devDependency. | ||
* Added -p, --path <path> flag to jade(1) | ||
* Added -p, --path <path> flag to pug(1) | ||
* Added support for any arbitrary doctype | ||
* Added `jade.render(str[,options], fn)` back | ||
* Added `pug.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: set .filename option in pug(1) when passing filenames | ||
* Fixed `Object.keys()` polyfill typo. Closes #331 | ||
@@ -587,3 +587,3 @@ * Fixed `include` error context | ||
* Fixed jade(1) support due to `res.render()` removal | ||
* Fixed pug(1) support due to `res.render()` removal | ||
* Removed --watch support (use a makefile + watch...) | ||
@@ -602,3 +602,3 @@ | ||
* Removed `Parser#debug()` | ||
* Removed `jade.render()` and `jade.renderFile()` | ||
* Removed `pug.render()` and `pug.renderFile()` | ||
* Fixed runtime.js `escape()` bug causing window.escape to be used | ||
@@ -610,3 +610,3 @@ * Fixed a bunch of tests | ||
* Added `include` support for non-jade files | ||
* Added `include` support for non-pug files | ||
* Fixed code indentation when followed by newline(s). Closes #295 [reported by masylum] | ||
@@ -731,4 +731,4 @@ | ||
* 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 | ||
* Added `pug.js` for the client-side to the repo | ||
* Added `pug.min.js` for the client-side to the repo | ||
* Removed need for pipes in filters. Closes #185 | ||
@@ -742,3 +742,3 @@ Note that this _will_ break filters used to | ||
* Added jade `--version` | ||
* Added pug `--version` | ||
* Removed `${}` interpolation support, use `#{}` | ||
@@ -754,3 +754,3 @@ | ||
* Added client-side browser support via `make jade.js` and `make jade.min.js`. | ||
* Added client-side browser support via `make pug.js` and `make pug.min.js`. | ||
@@ -765,3 +765,3 @@ 0.8.9 / 2011-03-15 | ||
* Fixed jade(1) stdio | ||
* Fixed pug(1) stdio | ||
@@ -771,7 +771,7 @@ 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] | ||
* Added `mkdirs()` to pug(1) | ||
* Added pug(1) stdio support | ||
* Added new features to pug(1), `--watch`, recursive compilation etc [khingebjerg] | ||
* Fixed pipe-less text newlines | ||
* Removed jade(1) `--pipe` flag | ||
* Removed pug(1) `--pipe` flag | ||
@@ -845,3 +845,3 @@ 0.8.6 / 2011-03-11 | ||
* Added CSRF example, showing how you can transparently add inputs to a form | ||
* Added link to vim-jade | ||
* Added link to vim-pug | ||
* Fixed self-closing col support [guillermo] | ||
@@ -899,7 +899,7 @@ * Fixed exception when getAttribute or removeAttribute run into removed attributes [Naitik Shah] | ||
Whitespace handling is a little tricky with this sort of grammar. | ||
Jade will now mimic the written grammar, meaning that text blocks | ||
Pug 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 | ||
This may not be ideal, but it makes more sense than what Pug was | ||
previously doing. | ||
@@ -972,4 +972,4 @@ | ||
* Added support for `jade.renderFile()` to utilize primed cache | ||
* Added link to [textmate bundle](http://github.com/miksago/jade-tmbundle) | ||
* Added support for `pug.renderFile()` to utilize primed cache | ||
* Added link to [textmate bundle](http://github.com/miksago/pug-tmbundle) | ||
* Fixed filter issue with single quotes | ||
@@ -976,0 +976,0 @@ * Fixed hyphenated attr bug |
114
lib/index.js
'use strict'; | ||
/*! | ||
* Jade | ||
* Pug | ||
* Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca> | ||
@@ -26,3 +26,3 @@ * MIT Licensed | ||
/** | ||
* Jade runtime helpers. | ||
* Pug runtime helpers. | ||
*/ | ||
@@ -44,3 +44,3 @@ | ||
/** | ||
* Compile the given `str` of jade and return a function body. | ||
* Compile the given `str` of pug and return a function body. | ||
* | ||
@@ -57,62 +57,50 @@ * @param {String} str | ||
var dependencies = []; | ||
try { | ||
var ast = load.string(str, options.filename, { | ||
lex: lex, | ||
parse: function (tokens, filename) { | ||
tokens = stripComments(tokens, { filename: filename }); | ||
return parse(tokens, filename); | ||
}, | ||
resolve: function (filename, source) { | ||
filename = filename.trim(); | ||
if (filename[0] !== '/' && !source) | ||
throw new Error('the "filename" option is required to use includes and extends with "relative" paths'); | ||
var ast = load.string(str, options.filename, { | ||
lex: lex, | ||
parse: function (tokens, filename) { | ||
tokens = stripComments(tokens, { filename: filename }); | ||
return parse(tokens, filename); | ||
}, | ||
resolve: function (filename, source) { | ||
filename = filename.trim(); | ||
if (filename[0] !== '/' && !source) | ||
throw new Error('the "filename" option is required to use includes and extends with "relative" paths'); | ||
if (filename[0] === '/' && !options.basedir) | ||
throw new Error('the "basedir" option is required to use includes and extends with "absolute" paths'); | ||
if (filename[0] === '/' && !options.basedir) | ||
throw new Error('the "basedir" option is required to use includes and extends with "absolute" paths'); | ||
filename = path.join(filename[0] === '/' ? options.basedir : path.dirname(source), filename); | ||
filename = path.join(filename[0] === '/' ? options.basedir : path.dirname(source), filename); | ||
if (path.basename(filename).indexOf('.') === -1) filename += '.jade'; | ||
if (path.basename(filename).indexOf('.') === -1) filename += '.pug'; | ||
return filename; | ||
}, | ||
read: function (filename) { | ||
dependencies.push(filename); | ||
var str = fs.readFileSync(filename, 'utf8'); | ||
debug_sources[filename] = str; | ||
return str; | ||
} | ||
}); | ||
ast = filters.handleFilters(ast, exports.filters); | ||
ast = link(ast); | ||
return filename; | ||
}, | ||
read: function (filename) { | ||
dependencies.push(filename); | ||
var str = fs.readFileSync(filename, 'utf8'); | ||
debug_sources[filename] = str; | ||
return str; | ||
} | ||
}); | ||
ast = filters.handleFilters(ast, exports.filters); | ||
ast = link(ast); | ||
// Compile | ||
var js = generateCode(ast, { | ||
pretty: options.pretty, | ||
compileDebug: options.compileDebug, | ||
doctype: options.doctype, | ||
inlineRuntimeFunctions: options.inlineRuntimeFunctions, | ||
globals: options.globals, | ||
self: options.self, | ||
includeSources: options.includeSources ? debug_sources : false, | ||
templateName: options.templateName | ||
}); | ||
// Compile | ||
var js = generateCode(ast, { | ||
pretty: options.pretty, | ||
compileDebug: options.compileDebug, | ||
doctype: options.doctype, | ||
inlineRuntimeFunctions: options.inlineRuntimeFunctions, | ||
globals: options.globals, | ||
self: options.self, | ||
includeSources: options.includeSources ? debug_sources : false, | ||
templateName: options.templateName | ||
}); | ||
// Debug compiler | ||
if (options.debug) { | ||
console.error('\nCompiled Function:\n\n\u001b[90m%s\u001b[0m', js.replace(/^/gm, ' ')); | ||
} | ||
// Debug compiler | ||
if (options.debug) { | ||
console.error('\nCompiled Function:\n\n\u001b[90m%s\u001b[0m', js.replace(/^/gm, ' ')); | ||
} | ||
return {body: js, dependencies: dependencies}; | ||
} catch (err) { | ||
if (err.code && typeof err.code === 'string' && err.code.substr(0, 4) === 'JADE') { | ||
runtime.rethrow( | ||
new Error(err.msg), | ||
err.filename, | ||
err.line, | ||
options.filename === err.filename ? str : (options.compileDebug ? debug_sources[err.filename] : undefined) | ||
); | ||
} | ||
throw err; | ||
} | ||
return {body: js, dependencies: dependencies}; | ||
} | ||
@@ -147,3 +135,3 @@ | ||
/** | ||
* Compile a `Function` representation of the given jade `str`. | ||
* Compile a `Function` representation of the given pug `str`. | ||
* | ||
@@ -192,3 +180,3 @@ * Options: | ||
/** | ||
* Compile a JavaScript source representation of the given jade `str`. | ||
* Compile a JavaScript source representation of the given pug `str`. | ||
* | ||
@@ -230,3 +218,3 @@ * Options: | ||
/** | ||
* Compile a JavaScript source representation of the given jade `str`. | ||
* Compile a JavaScript source representation of the given pug `str`. | ||
* | ||
@@ -250,3 +238,3 @@ * Options: | ||
/** | ||
* Compile a `Function` representation of the given jade file. | ||
* Compile a `Function` representation of the given pug file. | ||
* | ||
@@ -271,3 +259,3 @@ * Options: | ||
/** | ||
* Render the given `str` of jade. | ||
* Render the given `str` of pug. | ||
* | ||
@@ -312,3 +300,3 @@ * Options: | ||
/** | ||
* Render a Jade file at the given `path`. | ||
* Render a Pug file at the given `path`. | ||
* | ||
@@ -345,3 +333,3 @@ * @param {String} path | ||
/** | ||
* Compile a Jade file at the given `path` for use on the client. | ||
* Compile a Pug file at the given `path` for use on the client. | ||
* | ||
@@ -348,0 +336,0 @@ * @param {String} path |
{ | ||
"name": "pug", | ||
"description": "A clean, whitespace-sensitive template language for writing HTML", | ||
"version": "0.1.0", | ||
"version": "2.0.0-alpha1", | ||
"author": "TJ Holowaychuk <tj@vision-media.ca>", | ||
@@ -19,16 +19,13 @@ "maintainers": [ | ||
"type": "git", | ||
"url": "git://github.com/jadejs/jade" | ||
"url": "git://github.com/pugjs/pug" | ||
}, | ||
"main": "lib", | ||
"bin": { | ||
"jade": "./bin/jade.js" | ||
}, | ||
"dependencies": { | ||
"pug-code-gen": "0.0.0", | ||
"pug-filters": "1.1.0", | ||
"pug-lexer": "0.0.0", | ||
"pug-linker": "0.0.0", | ||
"pug-loader": "0.0.0", | ||
"pug-parser": "0.0.0", | ||
"pug-runtime": "0.0.0", | ||
"pug-code-gen": "0.0.7", | ||
"pug-filters": "1.1.1", | ||
"pug-lexer": "1.0.0", | ||
"pug-linker": "0.0.4", | ||
"pug-loader": "1.0.0", | ||
"pug-parser": "1.0.0", | ||
"pug-runtime": "2.0.0", | ||
"pug-strip-comments": "0.0.1" | ||
@@ -47,4 +44,2 @@ }, | ||
"istanbul": "*", | ||
"jade-code-mirror": "~1.0.5", | ||
"jade-highlighter": "~1.0.5", | ||
"jquery": "^2.1.4", | ||
@@ -59,3 +54,2 @@ "jstransformer-cdata": "^1.0.0", | ||
"less-file": "0.0.9", | ||
"linify": "*", | ||
"lsr": "^1.0.0", | ||
@@ -75,4 +69,3 @@ "markdown-it": "^5.0.1", | ||
"coverage": "istanbul cover node_modules/mocha/bin/_mocha -- -R dot", | ||
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls", | ||
"prepublish": "npm prune && linify transform bin" | ||
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls" | ||
}, | ||
@@ -82,3 +75,3 @@ "browser": { | ||
}, | ||
"homepage": "http://jade-lang.com" | ||
"homepage": "http://pug-lang.com" | ||
} |
@@ -1,4 +0,4 @@ | ||
# Jade - 模板引擎 | ||
# Pug - 模板引擎 | ||
Jade 是一个高性能的模板引擎,它深受 [Haml](http://haml-lang.com) 影响,它是用 JavaScript 实现的, 并且可以供 [Node](http://nodejs.org) 使用. | ||
Pug 是一个高性能的模板引擎,它深受 [Haml](http://haml-lang.com) 影响,它是用 JavaScript 实现的, 并且可以供 [Node](http://nodejs.org) 使用. | ||
@@ -9,13 +9,13 @@ 翻译: [草依山](http://jser.me) 等 | ||
**本文档已经非常过时了,所以很多例子都有可能无法使用。最新的范例可以在[官方英文文档](http://jade-lang.com/reference/)找到。** | ||
**本文档已经非常过时了,所以很多例子都有可能无法使用。最新的范例可以在[官方英文文档](http://pug-lang.com/reference/)找到。** | ||
从 Jade `v0.31.0` 开始放弃了对于 `<script>` 和 `<style>` 标签的平文本支持. 这个问题你可以在 `<script> <style>` 标签后加上 `.` 来解决. | ||
从 Pug `v0.31.0` 开始放弃了对于 `<script>` 和 `<style>` 标签的平文本支持. 这个问题你可以在 `<script> <style>` 标签后加上 `.` 来解决. | ||
希望这一点能让 Jade 对新手更友好, 同时也不影响到 Jade 本身的能力或者导致过度冗长. | ||
希望这一点能让 Pug 对新手更友好, 同时也不影响到 Pug 本身的能力或者导致过度冗长. | ||
如果你有大量的文件需要转换你可以用下 [fix-jade](https://github.com/ForbesLindesay/fix-jade) 尝试自动完成这个过程. | ||
如果你有大量的文件需要转换你可以用下 [fix-pug](https://github.com/ForbesLindesay/fix-pug) 尝试自动完成这个过程. | ||
## Test drive | ||
你可以在网上[试玩 Jade](http://naltatis.github.com/jade-syntax-docs). | ||
你可以在网上[试玩 Pug](http://naltatis.github.com/pug-syntax-docs). | ||
@@ -51,3 +51,3 @@ ## README 目录 | ||
- [Makefile 的一个例子](#a16) | ||
- [命令行的 Jade](#a17) | ||
- [命令行的 Pug](#a17) | ||
- [教程](#a18) | ||
@@ -68,3 +68,3 @@ - [License](#a19) | ||
- 运行时和编译时上下文错误报告 | ||
- 命令行下编译jade模板 | ||
- 命令行下编译pug模板 | ||
- HTML5 模式 (使用 ~~`!!! 5`~~ `doctype html` 文档类型) | ||
@@ -86,8 +86,8 @@ - 在内存中缓存(可选) | ||
- `:coffeescript` 必须已经安装[coffee-script](http://jashkenas.github.com/coffee-script/) | ||
- [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 | ||
- [Emacs Mode](https://github.com/brianc/pug-mode) | ||
- [Vim Syntax](https://github.com/digitaltoad/vim-pug) | ||
- [TextMate Bundle](http://github.com/miksago/pug-tmbundle) | ||
- [Coda/SubEtha syntax Mode](https://github.com/aaronmccall/pug.mode) | ||
- [Screencasts](http://tjholowaychuk.com/post/1004255394/pug-screencast-template-engine-for-nodejs) | ||
- [html2pug](https://github.com/donpark/html2pug) converter | ||
@@ -97,7 +97,7 @@ <a name="a2"/> | ||
- [php](http://github.com/everzet/jade.php) | ||
- [php](http://github.com/everzet/pug.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) | ||
- [python](https://github.com/SyrusAkbary/pypug) | ||
- [java](https://github.com/neuland/pug4j) | ||
@@ -110,3 +110,3 @@ <a name="a3"/> | ||
```sh | ||
npm install jade | ||
npm install pug | ||
``` | ||
@@ -117,6 +117,6 @@ | ||
把 Jade 编译为一个可供浏览器使用的单文件,只需要简单的执行: | ||
把 Pug 编译为一个可供浏览器使用的单文件,只需要简单的执行: | ||
```sh | ||
$ make jade.js | ||
$ make pug.js | ||
``` | ||
@@ -127,6 +127,6 @@ | ||
```sh | ||
make jade.min.js | ||
make pug.min.js | ||
``` | ||
默认情况下,为了方便调试Jade会把模板组织成带有形如 `__.lineno = 3` 的行号的形式。 | ||
默认情况下,为了方便调试Pug会把模板组织成带有形如 `__.lineno = 3` 的行号的形式。 | ||
在浏览器里使用的时候,你可以通过传递一个选项 `{ compileDebug: false }` 来去掉这个。 | ||
@@ -152,7 +152,7 @@ 下面的模板 | ||
通过使用 Jade 的 `./runtime.js`你可以在浏览器使用这些预编译的模板而不需要使用 Jade, 你只需要使用 `runtime.js` 里的工具函数, 它们会放在 `jade.attrs`, `jade.escape` 这些里。 把选项 `{ client: true }` 传递给 `jade.compile()`, Jade 会把这些帮助函数的引用放在`jade.attrs`, `jade.escape`. | ||
通过使用 Pug 的 `./runtime.js`你可以在浏览器使用这些预编译的模板而不需要使用 Pug, 你只需要使用 `runtime.js` 里的工具函数, 它们会放在 `pug.attrs`, `pug.escape` 这些里。 把选项 `{ client: true }` 传递给 `pug.compile()`, Pug 会把这些帮助函数的引用放在`pug.attrs`, `pug.escape`. | ||
```js | ||
function anonymous(locals, attrs, escape, rethrow) { | ||
var attrs = jade.attrs, escape = jade.escape, rethrow = jade.rethrow; | ||
var attrs = pug.attrs, escape = pug.escape, rethrow = pug.rethrow; | ||
var buf = []; | ||
@@ -171,6 +171,6 @@ with (locals || {}) { | ||
```javascript | ||
var jade = require('jade'); | ||
var pug = require('pug'); | ||
// Compile a function | ||
var fn = jade.compile('string of jade', options); | ||
var fn = pug.compile('string of pug', options); | ||
fn(locals); | ||
@@ -185,3 +185,3 @@ ``` | ||
- `debug` 输出 token 和翻译后的函数体 | ||
- `compiler` 替换掉 jade 默认的编译器 | ||
- `compiler` 替换掉 pug 默认的编译器 | ||
- `compileDebug` `false`的时候调试的结构不会被输出 | ||
@@ -203,3 +203,3 @@ - `pretty` 为输出加上了漂亮的空格缩进 _(默认为 `false`)_ | ||
```jade | ||
```pug | ||
html | ||
@@ -212,3 +212,3 @@ ``` | ||
```jade | ||
```pug | ||
div#container | ||
@@ -221,3 +221,3 @@ ``` | ||
```jade | ||
```pug | ||
div.user-details | ||
@@ -236,3 +236,3 @@ ``` | ||
```jade | ||
```pug | ||
#foo | ||
@@ -253,3 +253,3 @@ .bar | ||
```jade | ||
```pug | ||
p wahoo! | ||
@@ -262,3 +262,3 @@ ``` | ||
```jade | ||
```pug | ||
p | ||
@@ -268,3 +268,3 @@ | foo bar baz | ||
| super cool | ||
| go jade go | ||
| go pug go | ||
``` | ||
@@ -276,3 +276,3 @@ | ||
```jade | ||
```pug | ||
#user #{name} <#{email}> | ||
@@ -291,3 +291,3 @@ ``` | ||
```jade | ||
```pug | ||
- var html = "<script></script>" | ||
@@ -299,3 +299,3 @@ | !{html} | ||
```jade | ||
```pug | ||
label | ||
@@ -308,3 +308,3 @@ | Username: | ||
```jade | ||
```pug | ||
label Username: | ||
@@ -316,3 +316,3 @@ input(name='user[name]') | ||
```jade | ||
```pug | ||
html | ||
@@ -331,3 +331,3 @@ head | ||
```jade | ||
```pug | ||
p. | ||
@@ -343,3 +343,3 @@ foo asdf | ||
```jade | ||
```pug | ||
<p>foo asdf | ||
@@ -354,5 +354,5 @@ asdf | ||
这和带一个空格的 `.` 是不一样的, 带空格的会被 Jade 的解析器忽略,当作一个普通的文字: | ||
这和带一个空格的 `.` 是不一样的, 带空格的会被 Pug 的解析器忽略,当作一个普通的文字: | ||
```jade | ||
```pug | ||
p . | ||
@@ -363,3 +363,3 @@ ``` | ||
```jade | ||
```pug | ||
<p>.</p> | ||
@@ -370,3 +370,3 @@ ``` | ||
```jade | ||
```pug | ||
<p>foo\bar</p> | ||
@@ -377,3 +377,3 @@ ``` | ||
```jade | ||
```pug | ||
p. | ||
@@ -388,3 +388,3 @@ foo\\bar | ||
```jade | ||
```pug | ||
// just some paragraphs | ||
@@ -403,5 +403,5 @@ p foo | ||
Jade 同样支持不输出的注释,加一个短横线就行了: | ||
Pug 同样支持不输出的注释,加一个短横线就行了: | ||
```jade | ||
```pug | ||
//- will not output within markup | ||
@@ -424,3 +424,3 @@ p foo | ||
```jade | ||
```pug | ||
body | ||
@@ -441,5 +441,5 @@ // | ||
### 条件注释 | ||
对于条件注释,Jade 没有任何特殊的语法。因为 Jade 会把所有以 `<` 开始的代码处理为纯文本,您可以直接使用 HTML:: | ||
对于条件注释,Pug 没有任何特殊的语法。因为 Pug 会把所有以 `<` 开始的代码处理为纯文本,您可以直接使用 HTML:: | ||
```jade | ||
```pug | ||
body | ||
@@ -464,5 +464,5 @@ <!--[if IE]> | ||
Jade 支持以自然的方式定义标签嵌套: | ||
Pug 支持以自然的方式定义标签嵌套: | ||
```jade | ||
```pug | ||
ul | ||
@@ -482,3 +482,3 @@ li.first | ||
```jade | ||
```pug | ||
ul | ||
@@ -495,3 +495,3 @@ li.first: a(href='#') foo | ||
```jade | ||
```pug | ||
html | ||
@@ -511,3 +511,3 @@ body | ||
```jade | ||
```pug | ||
friends = 5 | ||
@@ -526,5 +526,5 @@ | ||
Jade 现在支持使用 `(` 和 `)` 作为属性分隔符 | ||
Pug 现在支持使用 `(` 和 `)` 作为属性分隔符 | ||
```jade | ||
```pug | ||
a(href='/login', title='View login page') Login | ||
@@ -536,3 +536,3 @@ ``` | ||
```jade | ||
```pug | ||
div(something=null) | ||
@@ -543,3 +543,3 @@ ``` | ||
```jade | ||
```pug | ||
input(type="checkbox", checked) | ||
@@ -550,3 +550,3 @@ ``` | ||
```jade | ||
```pug | ||
input(type="checkbox", checked=someValue) | ||
@@ -557,3 +557,3 @@ ``` | ||
```jade | ||
```pug | ||
input(type='checkbox', | ||
@@ -566,3 +566,3 @@ name='agreement', | ||
```jade | ||
```pug | ||
input(type='checkbox' | ||
@@ -575,3 +575,3 @@ name='agreement' | ||
```jade | ||
```pug | ||
input( | ||
@@ -585,3 +585,3 @@ type='checkbox' | ||
```jade | ||
```pug | ||
rss(xmlns:atom="atom") | ||
@@ -593,9 +593,9 @@ ``` | ||
```jade | ||
```pug | ||
a(href='/user/' + user.id)= user.name | ||
``` | ||
或者我们使用 Jade 的修改方式, 这个我想很多使用 Ruby 或者 CoffeeScript 的人会看起来像普通的 JS..: | ||
或者我们使用 Pug 的修改方式, 这个我想很多使用 Ruby 或者 CoffeeScript 的人会看起来像普通的 JS..: | ||
```jade | ||
```pug | ||
a(href='/user/#{user.id}')= user.name | ||
@@ -606,3 +606,3 @@ ``` | ||
```jade | ||
```pug | ||
body(class=bodyClasses) | ||
@@ -616,3 +616,3 @@ ``` | ||
```jade | ||
```pug | ||
html | ||
@@ -624,5 +624,5 @@ body | ||
或者我们可以使用 `.` 来告诉 Jade 我们需要一段文本: | ||
或者我们可以使用 `.` 来告诉 Pug 我们需要一段文本: | ||
```jade | ||
```pug | ||
html | ||
@@ -636,3 +636,3 @@ body. | ||
```jade | ||
```pug | ||
<html><body><h1>Title</h1> | ||
@@ -643,3 +643,3 @@ <p>foo bar baz</p> | ||
这条规则适应于在 Jade 里的任何文本: | ||
这条规则适应于在 Pug 里的任何文本: | ||
@@ -657,3 +657,3 @@ ``` | ||
```jade | ||
```pug | ||
!!! | ||
@@ -664,3 +664,3 @@ ``` | ||
```jade | ||
```pug | ||
!!! 5 | ||
@@ -671,3 +671,3 @@ ``` | ||
```jade | ||
```pug | ||
!!! html | ||
@@ -678,3 +678,3 @@ ``` | ||
```jade | ||
```pug | ||
doctype html | ||
@@ -685,3 +685,3 @@ ``` | ||
```jade | ||
```pug | ||
doctype Basic | ||
@@ -693,3 +693,3 @@ doctype basic | ||
```jade | ||
```pug | ||
doctype html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" | ||
@@ -723,3 +723,3 @@ ``` | ||
```javascript | ||
jade.doctypes.default = 'whatever you want'; | ||
pug.doctypes.default = 'whatever you want'; | ||
``` | ||
@@ -732,6 +732,6 @@ | ||
```jade | ||
```pug | ||
body | ||
:markdown | ||
Woah! jade _and_ markdown, very **cool** | ||
Woah! pug _and_ markdown, very **cool** | ||
we can even link to [stuff](http://google.com) | ||
@@ -743,3 +743,3 @@ ``` | ||
```html | ||
<body><p>Woah! jade <em>and</em> markdown, very <strong>cool</strong> we can even link to <a href="http://google.com">stuff</a></p></body> | ||
<body><p>Woah! pug <em>and</em> markdown, very <strong>cool</strong> we can even link to <a href="http://google.com">stuff</a></p></body> | ||
``` | ||
@@ -750,5 +750,5 @@ | ||
Jade 目前支持三种类型的可执行代码。第一种是前缀 `-`, 这是不会被输出的: | ||
Pug 目前支持三种类型的可执行代码。第一种是前缀 `-`, 这是不会被输出的: | ||
```jade | ||
```pug | ||
- var foo = 'bar'; | ||
@@ -759,3 +759,3 @@ ``` | ||
```jade | ||
```pug | ||
- for (var key in obj) | ||
@@ -765,5 +765,5 @@ p= obj[key] | ||
由于 Jade 的缓存技术,下面的代码也是可以的: | ||
由于 Pug 的缓存技术,下面的代码也是可以的: | ||
```jade | ||
```pug | ||
- if (foo) | ||
@@ -790,3 +790,3 @@ ul | ||
```jade | ||
```pug | ||
- var foo = 'bar' | ||
@@ -799,16 +799,16 @@ = foo | ||
```jade | ||
```pug | ||
p!= aVarContainingMoreHTML | ||
``` | ||
Jade 同样是设计师友好的,它可以使 JavaScript 更直接更富表现力。比如下面的赋值语句是相等的,同时表达式还是通常的 JavaScript: | ||
Pug 同样是设计师友好的,它可以使 JavaScript 更直接更富表现力。比如下面的赋值语句是相等的,同时表达式还是通常的 JavaScript: | ||
```jade | ||
```pug | ||
- var foo = 'foo ' + 'bar' | ||
foo = 'foo ' + 'bar' | ||
foo= 'foo ' + 'bar' | ||
``` | ||
Jade 会把 `if`, `else if`, `else`, `until`, `while`, `unless` 同别的优先对待, 但是你得记住它们还是普通的 JavaScript: | ||
Pug 会把 `if`, `else if`, `else`, `until`, `while`, `unless` 同别的优先对待, 但是你得记住它们还是普通的 JavaScript: | ||
```jade | ||
```pug | ||
if foo == 'bar' | ||
@@ -826,5 +826,5 @@ ul | ||
尽管已经支持 JavaScript 原生代码,Jade 还是支持了一些特殊的标签,它们可以让模板更加易于理解,其中之一就是 `each`, 这种形式: | ||
尽管已经支持 JavaScript 原生代码,Pug 还是支持了一些特殊的标签,它们可以让模板更加易于理解,其中之一就是 `each`, 这种形式: | ||
```jade | ||
```pug | ||
each VAL[, KEY] in OBJ | ||
@@ -835,3 +835,3 @@ ``` | ||
```jade | ||
```pug | ||
- var items = ["one", "two", "three"] | ||
@@ -852,3 +852,3 @@ each item in items | ||
```jade | ||
```pug | ||
items = ["one", "two", "three"] | ||
@@ -867,5 +867,5 @@ each item, i in items | ||
遍历一个数组的键值: | ||
遍历一个对象的键值: | ||
```jade | ||
```pug | ||
obj = { foo: 'bar' } | ||
@@ -878,5 +878,5 @@ each val, key in obj | ||
Jade 在内部会把这些语句转换成原生的 JavaScript 语句,就像使用 `users.forEach(function(user){`, 词法作用域和嵌套会像在普通的 JavaScript 中一样: | ||
Pug 在内部会把这些语句转换成原生的 JavaScript 语句,就像使用 `users.forEach(function(user){`, 词法作用域和嵌套会像在普通的 JavaScript 中一样: | ||
```jade | ||
```pug | ||
each user in users | ||
@@ -889,3 +889,3 @@ each role in user.roles | ||
```jade | ||
```pug | ||
for user in users | ||
@@ -899,6 +899,6 @@ for role in user.roles | ||
Jade 条件语句和使用了(`-`) 前缀的 JavaScript 语句是一致的,然后它允许你不使用圆括号,这样会看上去对设计师更友好一点, | ||
Pug 条件语句和使用了(`-`) 前缀的 JavaScript 语句是一致的,然后它允许你不使用圆括号,这样会看上去对设计师更友好一点, | ||
同时要在心里记住这个表达式渲染出的是 _常规_ JavaScript: | ||
```jade | ||
```pug | ||
for user in users | ||
@@ -913,3 +913,3 @@ if user.role == 'admin' | ||
```jade | ||
```pug | ||
for user in users | ||
@@ -922,5 +922,5 @@ - if (user.role == 'admin') | ||
Jade 同时支持 `unless`, 这和 `if (!(expr))` 是等价的: | ||
Pug 同时支持 `unless`, 这和 `if (!(expr))` 是等价的: | ||
```jade | ||
```pug | ||
for user in users | ||
@@ -936,7 +936,7 @@ unless user.isAnonymous | ||
Jade 支持通过 `block` 和 `extends` 关键字来实现模板继承。 一个块就是一个 Jade 的 block ,它将在子模板中实现,同时是支持递归的。 | ||
Pug 支持通过 `block` 和 `extends` 关键字来实现模板继承。 一个块就是一个 Pug 的 block ,它将在子模板中实现,同时是支持递归的。 | ||
Jade 块如果没有内容,Jade 会添加默认内容,下面的代码默认会输出 `block scripts`, `block content`, 和 `block foot`. | ||
Pug 块如果没有内容,Pug 会添加默认内容,下面的代码默认会输出 `block scripts`, `block content`, 和 `block foot`. | ||
```jade | ||
```pug | ||
html | ||
@@ -954,5 +954,5 @@ head | ||
现在我们来继承这个布局,简单创建一个新文件,像下面那样直接使用 `extends`,给定路径(可以选择带 `.jade` 扩展名或者不带). 你可以定义一个或者更多的块来覆盖父级块内容, 注意到这里的 `foot` 块 _没有_ 定义,所以它还会输出父级的 "some footer content"。 | ||
现在我们来继承这个布局,简单创建一个新文件,像下面那样直接使用 `extends`,给定路径(可以选择带 `.pug` 扩展名或者不带). 你可以定义一个或者更多的块来覆盖父级块内容, 注意到这里的 `foot` 块 _没有_ 定义,所以它还会输出父级的 "some footer content"。 | ||
```jade | ||
```pug | ||
extends extend-layout | ||
@@ -972,3 +972,3 @@ | ||
```jade | ||
```pug | ||
extends regular-layout | ||
@@ -989,6 +989,6 @@ | ||
Jade允许你 _替换_ (默认)、 _前置_ 和 _追加_ blocks. 比如,假设你希望在 _所有_ 页面的头部都加上默认的脚本,你可以这么做: | ||
Pug允许你 _替换_ (默认)、 _前置_ 和 _追加_ blocks. 比如,假设你希望在 _所有_ 页面的头部都加上默认的脚本,你可以这么做: | ||
```jade | ||
```pug | ||
html | ||
@@ -1006,3 +1006,3 @@ head | ||
```jade | ||
```pug | ||
extends layout | ||
@@ -1017,3 +1017,3 @@ | ||
```jade | ||
```pug | ||
extends layout | ||
@@ -1029,14 +1029,14 @@ | ||
Includes 允许你静态包含一段 Jade, 或者别的存放在单个文件中的东西比如 CSS, HTML 非常常见的例子是包含头部和页脚。 假设我们有一个下面目录结构的文件夹: | ||
Includes 允许你静态包含一段 Pug, 或者别的存放在单个文件中的东西比如 CSS, HTML 非常常见的例子是包含头部和页脚。 假设我们有一个下面目录结构的文件夹: | ||
``` | ||
./layout.jade | ||
./layout.pug | ||
./includes/ | ||
./head.jade | ||
./tail.jade | ||
./head.pug | ||
./tail.pug | ||
``` | ||
下面是 `layout.jade` 的内容: | ||
下面是 `layout.pug` 的内容: | ||
```jade | ||
```pug | ||
html | ||
@@ -1050,3 +1050,3 @@ include includes/head | ||
这两个包含 `includes/head` 和 `includes/foot` 都会读取相对于给 `layout.jade` 参数`filename` 的路径的文件, 这是一个绝对路径,不用担心Express帮你搞定这些了。Include 会解析这些文件,并且插入到已经生成的语法树中,然后渲染为你期待的内容: | ||
这两个包含 `includes/head` 和 `includes/foot` 都会读取相对于给 `layout.pug` 参数`filename` 的路径的文件, 这是一个绝对路径,不用担心Express帮你搞定这些了。Include 会解析这些文件,并且插入到已经生成的语法树中,然后渲染为你期待的内容: | ||
@@ -1070,3 +1070,3 @@ ```html | ||
前面已经提到,`include` 可以包含比如 HTML 或者 CSS 这样的内容。给定一个扩展名后,Jade 不会把这个文件当作一个 Jade 源代码,并且会把它当作一个普通文本包含进来: | ||
前面已经提到,`include` 可以包含比如 HTML 或者 CSS 这样的内容。给定一个扩展名后,Pug 不会把这个文件当作一个 Pug 源代码,并且会把它当作一个普通文本包含进来: | ||
@@ -1088,5 +1088,5 @@ ``` | ||
Include 也可以接受块内容,给定的块将会附加到包含文件 _最后_ 的块里。 举个例子,`head.jade` 包含下面的内容: | ||
Include 也可以接受块内容,给定的块将会附加到包含文件 _最后_ 的块里。 举个例子,`head.pug` 包含下面的内容: | ||
```jade | ||
```pug | ||
head | ||
@@ -1110,3 +1110,3 @@ script(src='/jquery.js') | ||
```jade | ||
```pug | ||
head | ||
@@ -1118,6 +1118,6 @@ yield | ||
由于被包含的Jade会按字面解析并合并到AST中,词法范围的变量的效果和直接写在同一个文件中的相同。这就意味着`include`可以用作partial的替代,例如,假设我们有一个引用了`user`变量的user.jade`文件: | ||
由于被包含的Pug会按字面解析并合并到AST中,词法范围的变量的效果和直接写在同一个文件中的相同。这就意味着`include`可以用作partial的替代,例如,假设我们有一个引用了`user`变量的user.pug`文件: | ||
```jade | ||
```pug | ||
h1= user.name | ||
@@ -1131,3 +1131,3 @@ p= user.occupation | ||
```jade | ||
```pug | ||
users = [{ name: 'Tobi', occupation: 'Ferret' }] | ||
@@ -1149,5 +1149,5 @@ | ||
`user.jade`引用了`user`变量,如果我们希望使用一个不同的变量`user`,那么我们可以直接定义一个新变量`user = person`,如下所示: | ||
`user.pug`引用了`user`变量,如果我们希望使用一个不同的变量`user`,那么我们可以直接定义一个新变量`user = person`,如下所示: | ||
```jade | ||
```pug | ||
each person in users | ||
@@ -1163,5 +1163,5 @@ .user | ||
Mixins 在编译的模板里会被 Jade 转换为普通的 JavaScript 函数。 Mixins 可以还参数,但不是必需的: | ||
Mixins 在编译的模板里会被 Pug 转换为普通的 JavaScript 函数。 Mixins 可以还参数,但不是必需的: | ||
```jade | ||
```pug | ||
mixin list | ||
@@ -1176,3 +1176,3 @@ ul | ||
```jade | ||
```pug | ||
h2 Groceries | ||
@@ -1184,3 +1184,3 @@ mixin list | ||
```jade | ||
```pug | ||
mixin pets(pets) | ||
@@ -1215,5 +1215,5 @@ ul.pets | ||
假设我们有下面的 Jade 源码: | ||
假设我们有下面的 Pug 源码: | ||
```jade | ||
```pug | ||
- var title = 'yay' | ||
@@ -1224,3 +1224,3 @@ h1.title #{title} | ||
当 `compileDebug` 选项不是 `false`, Jade 会编译时会把函数里加上 `__.lineno = n;`, 这个参数会在编译出错时传递给 `rethrow()`, 而这个函数会在 Jade 初始输出时给出一个有用的错误信息。 | ||
当 `compileDebug` 选项不是 `false`, Pug 会编译时会把函数里加上 `__.lineno = n;`, 这个参数会在编译出错时传递给 `rethrow()`, 而这个函数会在 Pug 初始输出时给出一个有用的错误信息。 | ||
@@ -1230,5 +1230,5 @@ ```js | ||
var __ = { lineno: 1, input: "- var title = 'yay'\nh1.title #{title}\np Just an example", filename: "testing/test.js" }; | ||
var rethrow = jade.rethrow; | ||
var rethrow = pug.rethrow; | ||
try { | ||
var attrs = jade.attrs, escape = jade.escape; | ||
var attrs = pug.attrs, escape = pug.escape; | ||
var buf = []; | ||
@@ -1257,7 +1257,7 @@ with (locals || {}) { | ||
当 `compileDebug` 参数是 `false`, 这个参数会被去掉,这样对于轻量级的浏览器端模板是非常有用的。结合 Jade 的参数和当前源码库里的 `./runtime.js` 文件,你可以通过 `toString()` 来编译模板而不需要在浏览器端运行整个 Jade 库,这样可以提高性能,也可以减少载入的 JavaScript 数量。 | ||
当 `compileDebug` 参数是 `false`, 这个参数会被去掉,这样对于轻量级的浏览器端模板是非常有用的。结合 Pug 的参数和当前源码库里的 `./runtime.js` 文件,你可以通过 `toString()` 来编译模板而不需要在浏览器端运行整个 Pug 库,这样可以提高性能,也可以减少载入的 JavaScript 数量。 | ||
```js | ||
function anonymous(locals) { | ||
var attrs = jade.attrs, escape = jade.escape; | ||
var attrs = pug.attrs, escape = pug.escape; | ||
var buf = []; | ||
@@ -1283,12 +1283,12 @@ with (locals || {}) { | ||
通过执行 `make`, 下面的 Makefile 例子可以把 `pages/*.jade` 编译为 `pages/*.html` 。 | ||
通过执行 `make`, 下面的 Makefile 例子可以把 `pages/*.pug` 编译为 `pages/*.html` 。 | ||
```make | ||
JADE = $(shell find pages/*.jade) | ||
HTML = $(JADE:.jade=.html) | ||
PUG = $(shell find pages/*.pug) | ||
HTML = $(PUG:.pug=.html) | ||
all: $(HTML) | ||
%.html: %.jade | ||
jade < $< --path $< > $@ | ||
%.html: %.pug | ||
pug < $< --path $< > $@ | ||
@@ -1308,7 +1308,7 @@ clean: | ||
<a name="a17"/> | ||
## 命令行的 Jade | ||
## 命令行的 Pug | ||
``` | ||
使用: jade [options] [dir|file ...] | ||
使用: pug [options] [dir|file ...] | ||
@@ -1330,18 +1330,18 @@ 选项: | ||
# 编译整个目录 | ||
$ jade templates | ||
$ pug templates | ||
# 生成 {foo,bar}.html | ||
$ jade {foo,bar}.jade | ||
$ pug {foo,bar}.pug | ||
# 在标准IO下使用jade | ||
$ jade < my.jade > my.html | ||
# 在标准IO下使用pug | ||
$ pug < my.pug > my.html | ||
# 在标准IO下使用jade, 同时指定用于查找包含的文件 | ||
$ jade < my.jade -p my.jade > my.html | ||
# 在标准IO下使用pug, 同时指定用于查找包含的文件 | ||
$ pug < my.pug -p my.pug > my.html | ||
# 在标准IO下使用jade | ||
$ echo "h1 Jade!" | jade | ||
# 在标准IO下使用pug | ||
$ echo "h1 Pug!" | pug | ||
# foo, bar 目录渲染到 /tmp | ||
$ jade foo bar --out /tmp | ||
$ pug foo bar --out /tmp | ||
@@ -1355,5 +1355,5 @@ ``` | ||
- 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) | ||
- in [Japanese](http://blog.craftgear.net/4f501e97c1347ec934000001/title/10%E5%88%86%E3%81%A7%E3%82%8F%E3%81%8B%E3%82%8Bjade%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%B3) | ||
- cssdeck interactive [Pug syntax tutorial](http://cssdeck.com/labs/learning-the-pug-templating-engine-syntax) | ||
- cssdeck interactive [Pug logic tutorial](http://cssdeck.com/labs/pug-templating-tutorial-codecast-part-2) | ||
- in [Japanese](http://blog.craftgear.net/4f501e97c1347ec934000001/title/10%E5%88%86%E3%81%A7%E3%82%8F%E3%81%8B%E3%82%8Bpug%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%B3) | ||
@@ -1360,0 +1360,0 @@ <a name="a19"/> |
@@ -1,18 +0,18 @@ | ||
# [![Jade - Node Template Engine](http://garthdb.com/img/jade_branding/jade-01.svg)](http://jade-lang.com/) | ||
# [![Pug - Node Template Engine](http://garthdb.com/img/pug_branding/pug-01.svg)](http://pug-lang.com/) | ||
Full documentation is at [jade-lang.com](http://jade-lang.com/) | ||
Full documentation is at [pug-lang.com](http://pug-lang.com/) | ||
Jade is a high performance template engine heavily influenced by [Haml](http://haml.info/) | ||
Pug is a high performance template engine heavily influenced by [Haml](http://haml.info/) | ||
and implemented with JavaScript for [node](http://nodejs.org) and browsers. For bug reports, | ||
feature requests and questions, [open an issue](https://github.com/jadejs/jade/issues/new). | ||
For discussion join the [chat room](https://gitter.im/jadejs/jade). | ||
feature requests and questions, [open an issue](https://github.com/pugjs/pug/issues/new). | ||
For discussion join the [chat room](https://gitter.im/pugjs/pug). | ||
You can test drive Jade online [here](http://naltatis.github.com/jade-syntax-docs). | ||
You can test drive Pug online [here](http://naltatis.github.com/pug-syntax-docs). | ||
[![Build Status](https://img.shields.io/travis/jadejs/jade/master.svg?style=flat)](https://travis-ci.org/jadejs/jade) | ||
[![Coverage Status](https://img.shields.io/coveralls/jadejs/jade/master.svg?style=flat)](https://coveralls.io/r/jadejs/jade?branch=master) | ||
[![Dependency Status](https://img.shields.io/david/jadejs/jade.svg?style=flat)](https://david-dm.org/jadejs/jade) | ||
[![devDependencies Status](https://img.shields.io/david/dev/jadejs/jade.svg?style=flat)](https://david-dm.org/jadejs/jade#info=devDependencies) | ||
[![NPM version](https://img.shields.io/npm/v/jade.svg?style=flat)](http://badge.fury.io/js/jade) | ||
[![Join Gitter Chat](https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg?style=flat)](https://gitter.im/jadejs/jade?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[![Build Status](https://img.shields.io/travis/pugjs/pug/master.svg?style=flat)](https://travis-ci.org/pugjs/pug) | ||
[![Coverage Status](https://img.shields.io/coveralls/pugjs/pug/master.svg?style=flat)](https://coveralls.io/r/pugjs/pug?branch=master) | ||
[![Dependency Status](https://img.shields.io/david/pugjs/pug.svg?style=flat)](https://david-dm.org/pugjs/pug) | ||
[![devDependencies Status](https://img.shields.io/david/dev/pugjs/pug.svg?style=flat)](https://david-dm.org/pugjs/pug#info=devDependencies) | ||
[![NPM version](https://img.shields.io/npm/v/pug.svg?style=flat)](https://www.npmjs.com/package/pug) | ||
[![Join Gitter Chat](https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg?style=flat)](https://gitter.im/pugjs/pug?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
@@ -24,3 +24,3 @@ ## Installation | ||
```bash | ||
$ npm install jade | ||
$ npm install pug | ||
``` | ||
@@ -30,5 +30,5 @@ | ||
Jade is a clean, whitespace sensitive syntax for writing html. Here is a simple example: | ||
Pug is a clean, whitespace sensitive syntax for writing html. Here is a simple example: | ||
```jade | ||
```pug | ||
doctype html | ||
@@ -41,5 +41,5 @@ html(lang="en") | ||
body | ||
h1 Jade - node template engine | ||
h1 Pug - node template engine | ||
#container.col | ||
if youAreUsingJade | ||
if youAreUsingPug | ||
p You are amazing | ||
@@ -49,3 +49,3 @@ else | ||
p. | ||
Jade is a terse and simple templating language with a | ||
Pug is a terse and simple templating language with a | ||
strong focus on performance and powerful features. | ||
@@ -61,3 +61,3 @@ ``` | ||
<head> | ||
<title>Jade</title> | ||
<title>Pug</title> | ||
<script type="text/javascript"> | ||
@@ -68,6 +68,6 @@ if (foo) bar(1 + 5) | ||
<body> | ||
<h1>Jade - node template engine</h1> | ||
<h1>Pug - node template engine</h1> | ||
<div id="container" class="col"> | ||
<p>You are amazing</p> | ||
<p>Jade is a terse and simple templating language with a strong focus on performance and powerful features.</p> | ||
<p>Pug is a terse and simple templating language with a strong focus on performance and powerful features.</p> | ||
</div> | ||
@@ -78,20 +78,20 @@ </body> | ||
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/jadejs/jade/blob/master/jade.md) and [here](https://github.com/jadejs/jade/blob/master/jade-language.md) | ||
The official [pug tutorial](http://pug-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/pugjs/pug/blob/master/pug.md) and [here](https://github.com/pugjs/pug/blob/master/pug-language.md) | ||
## API | ||
For full API, see [jade-lang.com/api](http://jade-lang.com/api/) | ||
For full API, see [pug-lang.com/api](http://pug-lang.com/api/) | ||
```js | ||
var jade = require('jade'); | ||
var pug = require('pug'); | ||
// compile | ||
var fn = jade.compile('string of jade', options); | ||
var fn = pug.compile('string of pug', options); | ||
var html = fn(locals); | ||
// render | ||
var html = jade.render('string of jade', merge(options, locals)); | ||
var html = pug.render('string of pug', merge(options, locals)); | ||
// renderFile | ||
var html = jade.renderFile('filename.jade', merge(options, locals)); | ||
var html = pug.renderFile('filename.pug', merge(options, locals)); | ||
``` | ||
@@ -107,3 +107,3 @@ | ||
The latest version of jade can be download for the browser in standalone form from [here](https://raw.githubusercontent.com/jadejs/jade/1.11.0/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://raw.githubusercontent.com/jadejs/jade/1.11.0/runtime.js) library on the client. | ||
The latest version of pug can be download for the browser in standalone form from [here](https://raw.githubusercontent.com/pugjs/pug/1.11.0/pug.js). It only supports the very latest browsers though, and is a large file. It is recommended that you pre-compile your pug templates to JavaScript and then just use the [runtime.js](https://raw.githubusercontent.com/pugjs/pug/1.11.0/runtime.js) library on the client. | ||
@@ -113,3 +113,3 @@ To compile a template for use on the client using the command line, do: | ||
```console | ||
$ jade --client --no-debug filename.jade | ||
$ pug --client --no-debug filename.pug | ||
``` | ||
@@ -124,3 +124,3 @@ | ||
```console | ||
$ npm install jade -g | ||
$ npm install pug -g | ||
``` | ||
@@ -131,3 +131,3 @@ | ||
```console | ||
$ jade --help | ||
$ pug --help | ||
``` | ||
@@ -139,24 +139,24 @@ | ||
- 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/jadejs/jade/blob/master/Readme_zh-cn.md) | ||
- cssdeck interactive [Pug syntax tutorial](http://cssdeck.com/labs/learning-the-pug-templating-engine-syntax) | ||
- cssdeck interactive [Pug logic tutorial](http://cssdeck.com/labs/pug-templating-tutorial-codecast-part-2) | ||
- [Pug について。](https://gist.github.com/japboy/5402844) (A Japanese Tutorial) | ||
- [Pug - 模板引擎](https://github.com/pugjs/pug/blob/master/Readme_zh-cn.md) | ||
Implementations in other languages: | ||
- [php](http://github.com/everzet/jade.php) | ||
- [php](https://github.com/kylekatarnls/pug-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) | ||
- [python](https://github.com/SyrusAkbary/pypug) | ||
- [java](https://github.com/neuland/pug4j) | ||
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) | ||
- [html2jade](https://github.com/donpark/html2jade) converter | ||
- [jade2php](https://github.com/SE7ENSKY/jade2php) converter | ||
- [Jade Server](https://github.com/ded/jade-server) Ideal for building local prototypes apart from any application | ||
- [Emacs Mode](https://github.com/brianc/pug-mode) | ||
- [Vim Syntax](https://github.com/digitaltoad/vim-pug) | ||
- [TextMate Bundle](http://github.com/miksago/pug-tmbundle) | ||
- [Coda/SubEtha syntax Mode](https://github.com/aaronmccall/pug.mode) | ||
- [html2pug](https://github.com/donpark/html2pug) converter | ||
- [pug2php](https://github.com/SE7ENSKY/pug2php) converter | ||
- [Pug Server](https://github.com/ded/pug-server) Ideal for building local prototypes apart from any application | ||
@@ -163,0 +163,0 @@ ## License |
@@ -1,7 +0,7 @@ | ||
var jade = require('./'); | ||
var resolvedJade = require.resolve('./'); | ||
var pug = require('./'); | ||
var resolvedPug = require.resolve('./'); | ||
function compileTemplate(module, filename) { | ||
var template = jade.compileFileClient(filename, {inlineRuntimeFunctions: false}); | ||
var body = "var jade = require('" + resolvedJade + "').runtime;\n\n" + | ||
var template = pug.compileFileClient(filename, {inlineRuntimeFunctions: false}); | ||
var body = "var pug = require('" + resolvedPug + "').runtime;\n\n" + | ||
"module.exports = " + template + ";"; | ||
@@ -12,3 +12,3 @@ module._compile(body, filename); | ||
if (require.extensions) { | ||
require.extensions['.jade'] = compileTemplate | ||
require.extensions['.pug'] = compileTemplate | ||
}; |
@@ -26,3 +26,3 @@ 'use strict'; | ||
}); | ||
return pr.commit('jadejs', 'jade', { | ||
return pr.commit('pugjs', 'pug', { | ||
branch: 'gh-pages', | ||
@@ -29,0 +29,0 @@ message: 'Update website for ' + version, |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
29
0
1
86709
11
377
+ Addedpug-attrs@2.0.4(transitive)
+ Addedpug-code-gen@0.0.7(transitive)
+ Addedpug-error@1.3.3(transitive)
+ Addedpug-filters@1.1.1(transitive)
+ Addedpug-lexer@1.0.0(transitive)
+ Addedpug-linker@0.0.4(transitive)
+ Addedpug-loader@1.0.0(transitive)
+ Addedpug-parser@1.0.0(transitive)
+ Addedpug-runtime@2.0.02.0.5(transitive)
+ Addedpug-walk@0.0.3(transitive)
- Removedpug-attrs@0.0.0(transitive)
- Removedpug-code-gen@0.0.0(transitive)
- Removedpug-filters@1.1.0(transitive)
- Removedpug-lexer@0.0.0(transitive)
- Removedpug-linker@0.0.0(transitive)
- Removedpug-loader@0.0.0(transitive)
- Removedpug-parser@0.0.0(transitive)
- Removedpug-runtime@0.0.0(transitive)
- Removedpug-walk@0.0.0(transitive)
Updatedpug-code-gen@0.0.7
Updatedpug-filters@1.1.1
Updatedpug-lexer@1.0.0
Updatedpug-linker@0.0.4
Updatedpug-loader@1.0.0
Updatedpug-parser@1.0.0
Updatedpug-runtime@2.0.0