diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-05-23 17:00:37 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-05-23 17:00:37 +0200 |
commit | 7c0b88cf2e1615e6c9e889052dbda31c3f8ad3f1 (patch) | |
tree | 3c2dd8a39cc477f00b1881764f0fd7bf0a67a650 /lib/generate/plugin.js | |
parent | bf21633b6c0f08f69452ceccf5e3c80dcbd62ad4 (diff) | |
download | gitbook-7c0b88cf2e1615e6c9e889052dbda31c3f8ad3f1.zip gitbook-7c0b88cf2e1615e6c9e889052dbda31c3f8ad3f1.tar.gz gitbook-7c0b88cf2e1615e6c9e889052dbda31c3f8ad3f1.tar.bz2 |
Plugins can extend html
Diffstat (limited to 'lib/generate/plugin.js')
-rw-r--r-- | lib/generate/plugin.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/generate/plugin.js b/lib/generate/plugin.js index 1edb62d..19eec86 100644 --- a/lib/generate/plugin.js +++ b/lib/generate/plugin.js @@ -160,6 +160,16 @@ Plugin.fromList = function(names, root) { }) .object() .value(); + resources.html = {} + + _.each(plugins, function(plugin) { + var html = plugin.infos.book.html || {}; + _.each(html, function(code, key) { + if (!_.isFunction(code)) code = _.constant(code); + if (!resources.html[key]) resources.html[key] = []; + resources.html[key].push(code); + }) + }); return Q({ 'list': plugins, @@ -179,6 +189,11 @@ Plugin.fromList = function(names, root) { if (!withTpl) return null; return withTpl.resolveFile(withTpl.infos.templates[name]); + }, + 'html': function(tag, context, options) { + return _.map(resources.html[tag] || [], function(code) { + return code.call(context, options); + }).join("\n"); } }); }; |