Skip to content
This repository has been archived by the owner on Jan 23, 2022. It is now read-only.

Commit

Permalink
Rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy351 committed Dec 27, 2015
1 parent 85d298b commit 5b98aee
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
coverage/
tmp/
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "hexo",
"root": true
}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.DS_Store
node_modules
node_modules/
tmp/
*.log
.idea/
coverage/
4 changes: 4 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"excludeFiles": ["node_modules/**", "coverage/**", "tmp/**"],
"preset": "hexo"
}
10 changes: 8 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
.git*
.DS_Store
test/
tmp/
coverage/
*.log
.jshintrc
.travis.yml
.idea/
appveyor.yml
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: node_js

sudo: false

cache:
apt: true
directories:
- node_modules

node_js:
- "0.12"
- "4"
- "5"

script:
- npm run eslint
- npm run jscs
- npm run test-cov

after_script:
- npm install coveralls
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [doT] renderer
# hexo-renderer-dot

[![npm version][npm-badge]][npm-url]
[![Build Status](https://travis-ci.org/hexojs/hexo-renderer-dot.svg?branch=master)](https://travis-ci.org/hexojs/hexo-renderer-dot) [![NPM version](https://badge.fury.io/js/hexo-renderer-dot.svg)](http://badge.fury.io/js/hexo-renderer-dot) [![Coverage Status](https://img.shields.io/coveralls/hexojs/hexo-renderer-dot.svg)](https://coveralls.io/r/hexojs/hexo-renderer-dot?branch=master)

Add support for [doT].

Expand All @@ -11,5 +11,3 @@ $ npm install hexo-renderer-dot --save
```

[doT]: http://olado.github.io/doT/
[npm-badge]: https://badge.fury.io/js/hexo-renderer-dot.svg
[npm-url]: https://badge.fury.io/js/hexo-renderer-dot
9 changes: 3 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
var Hexo = require('hexo');
var hexo = new Hexo(process.cwd(), {});
/* global hexo */

var dot = require('dot');
'use strict';

hexo.extend.renderer.register('dot', 'html', function(data, locals){
return dot.template(data.text)(locals);
}, true);
hexo.extend.renderer.register('dot', 'html', require('./lib/renderer'), true);
9 changes: 9 additions & 0 deletions lib/renderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

var dot = require('dot');

function dotRenderer(data, locals) {
return dot.template(data.text)(locals);
}

module.exports = dotRenderer;
29 changes: 18 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,30 @@
"version": "0.2.0",
"description": "doT renderer plugin for Hexo",
"main": "index",
"repository": {
"type": "git",
"url": "https://github.com/hexojs/hexo-renderer-dot.git"
},
"bugs": {
"url": "https://github.com/hexojs/hexo-renderer-dot/issues"
"scripts": {
"eslint": "eslint .",
"jscs": "jscs .",
"test": "mocha test/index.js",
"test-cov": "istanbul cover _mocha --print both test/index.js"
},
"repository": "hexojs/hexo-renderer-dot",
"keywords": [
"hexo",
"doT"
"doT",
"renderer"
],
"author": "Tommy Chen <tommy351@gmail.com> (http://zespia.tw)",
"license": {
"type": "MIT",
"url": "https://raw.github.com/tommy351/hexo/master/LICENSE"
},
"license": "MIT",
"dependencies": {
"dot": "^1.0.2"
},
"devDependencies": {
"chai": "^3.4.1",
"eslint": "^1.9.0",
"eslint-config-hexo": "^1.0.2",
"istanbul": "^0.4.0",
"jscs": "^2.5.1",
"jscs-preset-hexo": "^1.0.1",
"mocha": "^2.3.3"
}
}
3 changes: 3 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "hexo/test"
}
18 changes: 18 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

var should = require('chai').should(); // eslint-disable-line

describe('hexo-renderer-dot', function() {
var r = require('../lib/renderer');

it('default', function() {
var result = r({
text: 'Hi {{=it.name}}! {{=it.age}}'
}, {
name: 'John',
age: 31
});

result.should.eql('Hi John! 31');
});
});
1 change: 1 addition & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--reporter spec

0 comments on commit 5b98aee

Please sign in to comment.