@@ -6,7 +6,7 @@ var extend = require('util')._extend;
6
6
7
7
// Pattern properties
8
8
9
- var Pattern = function ( relPath , data ) {
9
+ var Pattern = function ( relPath , data , patternlab ) {
10
10
// We expect relPath to be the path of the pattern template, relative to the
11
11
// root of the pattern tree. Parse out the path parts and save the useful ones.
12
12
var pathObj = path . parse ( path . normalize ( relPath ) ) ;
@@ -44,6 +44,10 @@ var Pattern = function (relPath, data) {
44
44
// the joined pattern group and subgroup directory
45
45
this . flatPatternPath = this . subdir . replace ( / [ \/ \\ ] / g, '-' ) ; // '00-atoms-00-global'
46
46
47
+ // calculated path from the root of the public directory to the generated
48
+ // (rendered!) html file for this pattern, to be shown in the iframe
49
+ this . patternLink = patternlab ? this . getPatternLink ( patternlab , 'rendered' ) : null ;
50
+
47
51
// The canonical "key" by which this pattern is known. This is the callable
48
52
// name of the pattern. UPDATE: this.key is now known as this.patternPartial
49
53
this . patternPartial = this . patternGroup + '-' + this . patternBaseName ;
@@ -88,11 +92,6 @@ Pattern.prototype = {
88
92
var suffixConfig = patternlab . config . outputFileSuffixes ;
89
93
var suffix = suffixType ? suffixConfig [ suffixType ] : suffixConfig . rendered ;
90
94
91
- if ( this . patternLink ) {
92
- // Someone or something has explicitly set a patternLink on this pattern.
93
- // We had better respect that.
94
- return this . patternLink ;
95
- }
96
95
return this . name + path . sep + this . name + suffix + '.html' ;
97
96
} ,
98
97
@@ -123,16 +122,16 @@ Pattern.prototype = {
123
122
124
123
// factory: creates an empty Pattern for miscellaneous internal use, such as
125
124
// by list_item_hunter
126
- Pattern . createEmpty = function ( customProps ) {
127
- var pattern = new Pattern ( '' , null ) ;
125
+ Pattern . createEmpty = function ( customProps , patternlab ) {
126
+ var pattern = new Pattern ( '' , null , patternlab ) ;
128
127
return extend ( pattern , customProps ) ;
129
128
} ;
130
129
131
130
// factory: creates an Pattern object on-demand from a hash; the hash accepts
132
131
// parameters that replace the positional parameters that the Pattern
133
132
// constructor takes.
134
- Pattern . create = function ( relPath , data , customProps ) {
135
- var newPattern = new Pattern ( relPath || '' , data || null ) ;
133
+ Pattern . create = function ( relPath , data , customProps , patternlab ) {
134
+ var newPattern = new Pattern ( relPath || '' , data || null , patternlab ) ;
136
135
return extend ( newPattern , customProps ) ;
137
136
} ;
138
137
0 commit comments