Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit 1e35529

Browse files
committed
added encoded html and mustache versions of rendered patterns for the code viewer. fixes #73
1 parent 031d7e7 commit 1e35529

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

builder/patternlab.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ var patternlab_engine = function(){
1717
pa = require('./pattern_assembler'),
1818
mh = require('./media_hunter'),
1919
lh = require('./lineage_hunter'),
20-
pe = require('./pattern_exporter')
20+
pe = require('./pattern_exporter'),
21+
he = require('html-entities').AllHtmlEntities,
2122
patternlab = {};
2223

2324
patternlab.package =fs.readJSONSync('./package.json');
@@ -143,6 +144,8 @@ var patternlab_engine = function(){
143144
patternlab.patterns.push(currentPattern);
144145
});
145146

147+
var entity_encoder = new he();
148+
146149
//render all patterns last, so lineageR works
147150
patternlab.patterns.forEach(function(pattern, index, patterns){
148151

@@ -152,6 +155,14 @@ var patternlab_engine = function(){
152155
//write the compiled template to the public patterns directory
153156
fs.outputFileSync('./public/patterns/' + pattern.patternLink, patternlab.header + pattern.patternPartial + patternFooter);
154157

158+
//write the mustache file too
159+
fs.outputFileSync('./public/patterns/' + pattern.patternLink.replace('.html', '.mustache'), entity_encoder.encode(pattern.template));
160+
161+
//write the encoded version too
162+
fs.outputFileSync('./public/patterns/' + pattern.patternLink.replace('.html', '.escaped.html'), entity_encoder.encode(pattern.patternPartial));
163+
164+
165+
155166
});
156167

157168
//export patterns if necessary

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"mustache": "^1.0.0",
1616
"matchdep": "^0.3.0",
1717
"fs-extra": "^0.14.0",
18-
"diveSync": "^0.2.1"
18+
"diveSync": "^0.2.1",
19+
"html-entities": "^1.1.1"
1920
},
2021
"keywords": [
2122
"Pattern Lab",

0 commit comments

Comments
 (0)