Skip to content

Commit 436dd99

Browse files
committed
Add ability to export raw patterns.
Exporting "raw" patterns means that the export task is little more than a wrapper around a more condensed file naming method. Instead of outputting rendered HTML, the exporter outputs the raw patterns, augmented to remove any superfluous directory structure and prefixed ordering.
1 parent 410032e commit 436dd99

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

core/lib/pattern_exporter.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,21 @@ var pattern_exporter = function () {
4242
var preserveDirStructure = patternlab.config.patternExportPreserveDirectoryStructure;
4343
var patternName = pattern.patternPartial;
4444
var patternDir = patternlab.config.patternExportDirectory;
45+
var patternCode = pattern.patternPartialCode;
46+
var patternFileExtension = ".html";
4547
if (preserveDirStructure) {
4648
// Extract the first part of the pattern partial as the directory in which
4749
// it should go.
4850
patternDir = path.join(patternDir, pattern.patternPartial.split('-')[0]);
4951
patternName = pattern.patternPartial.split('-').slice(1).join('-');
5052
}
5153

52-
fs.outputFileSync(path.join(patternDir, patternName) + '.html', pattern.patternPartialCode);
54+
if (patternlab.config.patternExportRaw) {
55+
patternCode = pattern.extendedTemplate;
56+
patternFileExtension = "." + JSON.parse(pattern.patternData).patternExtension;
57+
}
58+
59+
fs.outputFileSync(path.join(patternDir, patternName) + patternFileExtension, patternCode);
5360
}
5461

5562
return {

patternlab-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
},
5555
"patternExportAll": false,
5656
"patternExportPreserveDirectoryStructure": false,
57+
"patternExportRaw": false,
5758
"patternExportPatternPartials": [],
5859
"patternExportDirectory": "./pattern_exports/",
5960
"cacheBust": true,

0 commit comments

Comments
 (0)