@@ -6,7 +6,7 @@ var extend = require('util')._extend;
66
77// Pattern properties
88
9- var Pattern = function ( relPath , data ) {
9+ var Pattern = function ( relPath , data , patternlab ) {
1010 // We expect relPath to be the path of the pattern template, relative to the
1111 // root of the pattern tree. Parse out the path parts and save the useful ones.
1212 var pathObj = path . parse ( path . normalize ( relPath ) ) ;
@@ -44,6 +44,10 @@ var Pattern = function (relPath, data) {
4444 // the joined pattern group and subgroup directory
4545 this . flatPatternPath = this . subdir . replace ( / [ \/ \\ ] / g, '-' ) ; // '00-atoms-00-global'
4646
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+
4751 // The canonical "key" by which this pattern is known. This is the callable
4852 // name of the pattern. UPDATE: this.key is now known as this.patternPartial
4953 this . patternPartial = this . patternGroup + '-' + this . patternBaseName ;
@@ -88,11 +92,6 @@ Pattern.prototype = {
8892 var suffixConfig = patternlab . config . outputFileSuffixes ;
8993 var suffix = suffixType ? suffixConfig [ suffixType ] : suffixConfig . rendered ;
9094
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- }
9695 return this . name + path . sep + this . name + suffix + '.html' ;
9796 } ,
9897
@@ -123,16 +122,16 @@ Pattern.prototype = {
123122
124123// factory: creates an empty Pattern for miscellaneous internal use, such as
125124// 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 ) ;
128127 return extend ( pattern , customProps ) ;
129128} ;
130129
131130// factory: creates an Pattern object on-demand from a hash; the hash accepts
132131// parameters that replace the positional parameters that the Pattern
133132// 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 ) ;
136135 return extend ( newPattern , customProps ) ;
137136} ;
138137
0 commit comments