├── .eslintignore ├── .eslintrc ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── index.js ├── lib ├── jade.js └── pug.js ├── package.json └── test ├── .eslintrc ├── index.js └── mocha.opts /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | coverage/ 3 | tmp/ -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "hexo", 3 | "root": true 4 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | tmp/ 4 | *.log 5 | .idea/ 6 | .nyc_output/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | sudo: false 4 | 5 | cache: 6 | apt: true 7 | directories: 8 | - node_modules 9 | 10 | node_js: 11 | - "8" 12 | - "10" 13 | - "node" 14 | 15 | script: 16 | - npm run eslint 17 | - npm run test-cov 18 | 19 | after_script: 20 | - npm install coveralls 21 | - nyc report --reporter=text-lcov | coveralls 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Tommy Chen 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hexo-renderer-jade 2 | [![Build Status](https://travis-ci.org/hexojs/hexo-renderer-jade.svg?branch=master)](https://travis-ci.org/hexojs/hexo-renderer-jade) 3 | [![NPM version](https://badge.fury.io/js/hexo-renderer-jade.svg)](https://www.npmjs.com/package/hexo-renderer-jade) 4 | [![Coverage Status](https://img.shields.io/coveralls/hexojs/hexo-renderer-jade.svg)](https://coveralls.io/r/hexojs/hexo-renderer-jade?branch=master) 5 | 6 | Support [Pug] and Jade templates. `*.pug` and `*.jade` files are rendered using Pug and Jade engine respectively. 7 | 8 | ## Deprecated 9 | 10 | Replaced by [hexo-renderer-pug](https://github.com/hexojs/hexo-renderer-pug). To migrate to that plugin, simply rename all `*.jade` files to `*.pug` and remove this plugin from your `package.json`. 11 | 12 | ## Install 13 | 14 | ``` bash 15 | $ npm install hexo-renderer-jade --save 16 | ``` 17 | 18 | [Pug]: http://pugjs.org/ 19 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* global hexo */ 2 | 'use strict'; 3 | 4 | hexo.extend.renderer.register('pug', 'html', require('./lib/pug'), true); 5 | hexo.extend.renderer.register('jade', 'html', require('./lib/jade'), true); 6 | -------------------------------------------------------------------------------- /lib/jade.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const jade = require('jade'); 4 | 5 | function jadeCompile(data) { 6 | return jade.compile(data.text, { 7 | filename: data.path 8 | }); 9 | } 10 | 11 | function jadeRenderer(data, locals) { 12 | return jadeCompile(data)(locals); 13 | } 14 | 15 | jadeRenderer.compile = jadeCompile; 16 | 17 | module.exports = jadeRenderer; 18 | -------------------------------------------------------------------------------- /lib/pug.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const pug = require('pug'); 4 | 5 | function pugCompile(data) { 6 | return pug.compile(data.text, { 7 | filename: data.path 8 | }); 9 | } 10 | 11 | function pugRenderer(data, locals) { 12 | return pugCompile(data)(locals); 13 | } 14 | 15 | pugRenderer.compile = pugCompile; 16 | 17 | module.exports = pugRenderer; 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hexo-renderer-jade", 3 | "version": "0.5.0", 4 | "description": "Pug/Jade renderer plugin for Hexo", 5 | "main": "index.js", 6 | "scripts": { 7 | "eslint": "eslint .", 8 | "test": "mocha test/index.js", 9 | "test-cov": "nyc npm run test" 10 | }, 11 | "directories": { 12 | "lib": "./lib" 13 | }, 14 | "files": [ 15 | "lib/", 16 | "index.js" 17 | ], 18 | "repository": "hexojs/hexo-renderer-jade", 19 | "keywords": [ 20 | "hexo", 21 | "jade", 22 | "pug", 23 | "renderer" 24 | ], 25 | "author": "Tommy Chen (http://zespia.tw)", 26 | "maintainers": [ 27 | "Abner Chou (http://abnerchou.me)" 28 | ], 29 | "license": "MIT", 30 | "dependencies": { 31 | "pug": "^2.0.1", 32 | "jade": "^1.11.0" 33 | }, 34 | "devDependencies": { 35 | "chai": "^4.2.0", 36 | "eslint": "^6.1.0", 37 | "eslint-config-hexo": "^3.0.0", 38 | "mocha": "^6.0.1", 39 | "nyc": "^14.1.1", 40 | "babel-eslint": "^10.0.1" 41 | }, 42 | "engines": { 43 | "node": ">=8.6.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "hexo/test" 3 | } -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const should = require('chai').should(); // eslint-disable-line 4 | 5 | describe('hexo-renderer-jade', () => { 6 | const jade = require('../lib/jade'); 7 | const pug = require('../lib/pug'); 8 | 9 | // Jade test cases 10 | it('jade - default', () => { 11 | const result = jade({ 12 | text: 'p Hello #{name}' 13 | }, { 14 | name: 'Hexo' 15 | }); 16 | 17 | result.should.eql('

Hello Hexo

'); 18 | }); 19 | 20 | it('jade - compile', () => { 21 | const render = jade.compile({ 22 | text: 'p Hello #{name}' 23 | }); 24 | 25 | const result = render({ 26 | name: 'Hexo' 27 | }); 28 | 29 | result.should.eql('

Hello Hexo

'); 30 | }); 31 | 32 | // Pug test cases 33 | it('pug - default', () => { 34 | const result = pug({ 35 | text: 'p Hello #{name}' 36 | }, { 37 | name: 'Hexo' 38 | }); 39 | 40 | result.should.eql('

Hello Hexo

'); 41 | }); 42 | 43 | it('pug - compile', () => { 44 | const render = pug.compile({ 45 | text: 'p Hello #{name}' 46 | }); 47 | 48 | const result = render({ 49 | name: 'Hexo' 50 | }); 51 | 52 | result.should.eql('

Hello Hexo

'); 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /test/mocha.opts: -------------------------------------------------------------------------------- 1 | --reporter spec --------------------------------------------------------------------------------