summaryrefslogtreecommitdiffstats
path: root/lib/templating
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-01-27 10:24:06 +0100
committerSamy Pessé <samypesse@gmail.com>2016-01-27 10:24:06 +0100
commitf305d57ab7702c3ca10fd6e32366d19e524ee1f0 (patch)
tree381ccb09c7cedc72cdf8ad6c98b681b72f4d1bc0 /lib/templating
parent877f2e477b010f9f37a9044606f110a90f077680 (diff)
downloadgitbook-f305d57ab7702c3ca10fd6e32366d19e524ee1f0.zip
gitbook-f305d57ab7702c3ca10fd6e32366d19e524ee1f0.tar.gz
gitbook-f305d57ab7702c3ca10fd6e32366d19e524ee1f0.tar.bz2
Add more classes structures
Diffstat (limited to 'lib/templating')
-rw-r--r--lib/templating/blocks.js11
-rw-r--r--lib/templating/index.js28
-rw-r--r--lib/templating/loader.js0
3 files changed, 39 insertions, 0 deletions
diff --git a/lib/templating/blocks.js b/lib/templating/blocks.js
new file mode 100644
index 0000000..92097a7
--- /dev/null
+++ b/lib/templating/blocks.js
@@ -0,0 +1,11 @@
+var _ = require('lodash');
+
+module.exports = {
+ // Return non-parsed html
+ // since blocks are by default non-parsable, a simple identity method works fine
+ html: _.identity,
+
+ // Highlight a code block
+ // This block can be extent by plugins
+ code: _.identity
+};
diff --git a/lib/templating/index.js b/lib/templating/index.js
new file mode 100644
index 0000000..1031bdb
--- /dev/null
+++ b/lib/templating/index.js
@@ -0,0 +1,28 @@
+var nunjucks = require('nunjucks');
+
+function TemplatingEngine(book) {
+ this.book = book;
+ this.log = book.log;
+
+
+ this.nunjucks = new nunjucks.Environment(
+ this.loader,
+ {
+ // Escaping is done after by the asciidoc/markdown parser
+ autoescape: false,
+
+ // Syntax
+ tags: {
+ blockStart: '{%',
+ blockEnd: '%}',
+ variableStart: '{{',
+ variableEnd: '}}',
+ commentStart: '{###',
+ commentEnd: '###}'
+ }
+ }
+ );
+}
+
+
+module.exports = TemplatingEngine;
diff --git a/lib/templating/loader.js b/lib/templating/loader.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/templating/loader.js