summaryrefslogtreecommitdiffstats
path: root/lib/template.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-03-14 23:23:28 +0100
committerSamy Pessé <samypesse@gmail.com>2015-03-14 23:23:28 +0100
commit94485621560152cf197dc8bd603774c46de2f0ef (patch)
tree189aa8349423187a807dd2c2a4b3639d1a752213 /lib/template.js
parent8320484b88f2481dad276b1912831110fdf75bcd (diff)
downloadgitbook-94485621560152cf197dc8bd603774c46de2f0ef.zip
gitbook-94485621560152cf197dc8bd603774c46de2f0ef.tar.gz
gitbook-94485621560152cf197dc8bd603774c46de2f0ef.tar.bz2
Add editorconfig and normalize indent
Diffstat (limited to 'lib/template.js')
-rw-r--r--lib/template.js80
1 files changed, 40 insertions, 40 deletions
diff --git a/lib/template.js b/lib/template.js
index 28b11c6..320c8bf 100644
--- a/lib/template.js
+++ b/lib/template.js
@@ -12,31 +12,31 @@ var pkg = require("../package.json");
// The loader should handle relative and git url
var BookLoader = nunjucks.Loader.extend({
- async: true,
+ async: true,
init: function(book) {
- this.book = book;
+ this.book = book;
},
getSource: function(fileurl, callback) {
- var that = this;
-
- git.resolveFile(fileurl)
- .then(function(filepath) {
- // Is local file
- if (!filepath) filepath = path.resolve(that.book.root, fileurl);
- else that.book.log.debug.ln("resolve from git", fileurl, "to", filepath)
-
- // Read file from absolute path
- return fs.readFile(filepath)
- .then(function(source) {
- return {
- src: source.toString(),
- path: filepath
- }
- });
- })
- .nodeify(callback);
+ var that = this;
+
+ git.resolveFile(fileurl)
+ .then(function(filepath) {
+ // Is local file
+ if (!filepath) filepath = path.resolve(that.book.root, fileurl);
+ else that.book.log.debug.ln("resolve from git", fileurl, "to", filepath)
+
+ // Read file from absolute path
+ return fs.readFile(filepath)
+ .then(function(source) {
+ return {
+ src: source.toString(),
+ path: filepath
+ }
+ });
+ })
+ .nodeify(callback);
},
resolve: function(from, to) {
@@ -46,27 +46,27 @@ var BookLoader = nunjucks.Loader.extend({
var TemplateEngine = function(book) {
- this.book = book;
+ this.book = book;
this.log = this.book.log;
- // Nunjucks env
- this.env = new nunjucks.Environment(
- new BookLoader(book),
- {
- // Escaping is done after by the markdown parser
- autoescape: false,
-
- // Tags
- tags: {
- blockStart: '{%',
- blockEnd: '%}',
- variableStart: '{{',
- variableEnd: '}}',
- commentStart: '{###',
- commentEnd: '###}'
- }
- }
- );
+ // Nunjucks env
+ this.env = new nunjucks.Environment(
+ new BookLoader(book),
+ {
+ // Escaping is done after by the markdown parser
+ autoescape: false,
+
+ // Tags
+ tags: {
+ blockStart: '{%',
+ blockEnd: '%}',
+ variableStart: '{{',
+ variableEnd: '}}',
+ commentStart: '{###',
+ commentEnd: '###}'
+ }
+ }
+ );
// List of tags shortcuts
this.shortcuts = [];
@@ -336,7 +336,7 @@ TemplateEngine.prototype.renderString = function(content, context, options) {
// Render a file from the book
TemplateEngine.prototype.renderFile = function(filename, options) {
- var that = this, context;
+ var that = this, context;
return that.book.readFile(filename)
.then(function(content) {