summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-10-03 23:34:27 +0200
committerSamy Pesse <samypesse@gmail.com>2016-10-03 23:34:27 +0200
commit84315a99f13adee0b96b6b12191f40a8012e32d1 (patch)
tree2744eae8600872f40ce7ea74b9eb4598e22e8532 /packages/gitbook-core
parent026cc8304d38d7fc9bd02e9978ff52416eabbec0 (diff)
downloadgitbook-84315a99f13adee0b96b6b12191f40a8012e32d1.zip
gitbook-84315a99f13adee0b96b6b12191f40a8012e32d1.tar.gz
gitbook-84315a99f13adee0b96b6b12191f40a8012e32d1.tar.bz2
First handling of templating blocks
Diffstat (limited to 'packages/gitbook-core')
-rw-r--r--packages/gitbook-core/package.json1
-rw-r--r--packages/gitbook-core/src/components/HTMLContent.js10
2 files changed, 7 insertions, 4 deletions
diff --git a/packages/gitbook-core/package.json b/packages/gitbook-core/package.json
index c6cfeed..4e3974e 100644
--- a/packages/gitbook-core/package.json
+++ b/packages/gitbook-core/package.json
@@ -6,6 +6,7 @@
"dependencies": {
"bluebird": "^3.4.6",
"classnames": "^2.2.5",
+ "entities": "^1.1.1",
"history": "^4.3.0",
"html-tags": "^1.1.1",
"immutable": "^3.8.1",
diff --git a/packages/gitbook-core/src/components/HTMLContent.js b/packages/gitbook-core/src/components/HTMLContent.js
index 4ce41f6..338e745 100644
--- a/packages/gitbook-core/src/components/HTMLContent.js
+++ b/packages/gitbook-core/src/components/HTMLContent.js
@@ -1,6 +1,7 @@
const React = require('react');
const ReactSafeHtml = require('react-safe-html');
const htmlTags = require('html-tags');
+const entities = require('entities');
const { InjectedComponent } = require('./InjectedComponent');
@@ -27,11 +28,12 @@ function inject(injectedProps, Component) {
}
const COMPONENTS = {
- // Templating blocks are exported as <template-block block="youtube" props="{}" />
- 'template-block': inject(
- ({block, props}) => {
+ // Templating blocks are exported as <xblock name="youtube" props="{}" />
+ 'xblock': inject(
+ ({name, props}) => {
+ props = entities.decodeHTML(props);
return {
- matching: { role: `block:${block}` },
+ matching: { role: `block:${name}` },
props: JSON.parse(props)
};
},