Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit 9a75665

Browse files
committed
Added handlebars helpers.
1 parent e0e68f0 commit 9a75665

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

helpers.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const Handlebars = require('handlebars');
2+
3+
const hljs = require('highlight.js');
4+
const markdown = require('markdown-it')({
5+
highlight (code) {
6+
7+
return hljs.highlight('javascript', code).value;
8+
9+
},
10+
'html': true,
11+
'linkify': true
12+
});
13+
14+
Handlebars.registerHelper('highlightBlock', block => {
15+
16+
if (block) {
17+
18+
return hljs.highlight('javascript', block).value;
19+
20+
}
21+
22+
return null;
23+
24+
});
25+
26+
Handlebars.registerHelper('markdown', block => {
27+
28+
if (block) {
29+
30+
return markdown.render(block);
31+
32+
}
33+
34+
return null;
35+
36+
});

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const path = require('path');
33

44
const Handlebars = require('handlebars');
55

6+
require('./helpers');
7+
68
/**
79
* Custom Handlebars template plugin for doxdox.
810
*

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
},
99
"license": "MIT",
1010
"dependencies": {
11-
"handlebars": "4.0.6"
11+
"handlebars": "4.0.6",
12+
"highlight.js": "9.8.0",
13+
"markdown-it": "8.1.0"
1214
},
1315
"devDependencies": {
1416
"@neogeek/eslint-config-standards": "1.8.0",
@@ -23,7 +25,8 @@
2325
"keywords": [
2426
"doxdox",
2527
"plugin",
26-
"handlebars"
28+
"handlebars",
29+
"markdown"
2730
],
2831
"authors": [
2932
{

0 commit comments

Comments
 (0)