<commit_before>/*
 * patternlab-node - v0.14.0 - 2015
 *
 * <NAME>, and the web community.
 * Licensed under the MIT license.
 *
 * Many thanks to <NAME> and <NAME> for inspiration, encouragement, and advice.
 *
 */

(function () {
  "use strict";

  var patternEngines = require('./pattern_engines/pattern_engines');
  var path = require('path');

  // oPattern properties

  var oPattern = function(abspath, subdir, filename, data){
    console.log('NEW OPATTERN.  ', 'absPath:', abspath, 'subdir:', subdir, 'filename:', filename, 'data:', data);
    this.fileName = filename.substring(0, filename.indexOf('.'));
    this.fileExtension = path.extname(abspath);
    this.abspath = abspath;
    this.subdir = subdir;
    this.name = subdir.replace(/[\/\\]/g, '-') + '-' + this.fileName; //this is the unique name with the subDir
    this.jsonFileData = data || {};
    this.patternName = this.fileName.replace(/^\d*\-/, '');
    this.patternDisplayName = this.patternName.split('-').reduce(function(val, working){
      return val.charAt(0).toUpperCase() + val.slice(1) + ' ' + working.charAt(0).toUpperCase() + working.slice(1);
    }, '').trim(); //this is the display name for the ui. strip numeric + hyphen prefixes
    this.patternLink = this.name + '/' + this.name + '.html';
    this.patternGroup = this.name.substring(this.name.indexOf('-') + 1, this.name.indexOf('-', 4) + 1 - this.name.indexOf('-') + 1);
    this.patternSubGroup = subdir.substring(subdir.indexOf('/') + 4);
    this.flatPatternPath = subdir.replace(/[\/\\]/g, '-');
    this.key = this.patternGroup + '-' + this.patternName;
    this.template = '';
    this.patternPartial = '';
    this.lineage = [];
    this.lineageIndex = [];
    this.lineageR = [];
    this.lineageRIndex = [];
    this.isPseudoPattern = false;
    this.engine = patternEngines.getEngineForPattern(this);
  };

  // oPattern methods

  // render method on oPatterns; this acts as a proxy for the PatternEngine's
  // render function
  oPattern.prototype.render = function (data, partials) {
    if (this.isPseudoPattern) {
      console.log(this.name + ' is a pseudo-pattern');
    } else {
      console.log('this is NOT a pseudo-pattern');
    }
    // console.log('this does ' + (this.template ? '' : 'NOT ') + 'have template');
    // console.log('this does ' + (this.extendedTemplate ? '' : 'NOT ') + 'have extendedTemplate');

    return this.engine.renderPattern(this.template, data, partials);
  };<commit_msg>fix homepage pattern and its pseudo-pattern not rendering<commit_after>/*
 * patternlab-node - v0.14.0 - 2015
 *
 * <NAME>, and the web community.
 * Licensed under the MIT license.
 *
 * Many thanks to <NAME> and <NAME> for inspiration, encouragement, and advice.
 *
 */

(function () {
  "use strict";

  var patternEngines = require('./pattern_engines/pattern_engines');
  var path = require('path');

  // oPattern properties

  var oPattern = function(abspath, subdir, filename, data){
    console.log('NEW OPATTERN.  ', 'absPath:', abspath, 'subdir:', subdir, 'filename:', filename, 'data:', data);
    this.fileName = filename.substring(0, filename.indexOf('.'));
    this.fileExtension = path.extname(abspath);
    this.abspath = abspath;
    this.subdir = subdir;
    this.name = subdir.replace(/[\/\\]/g, '-') + '-' + this.fileName; //this is the unique name with the subDir
    this.jsonFileData = data || {};
    this.patternName = this.fileName.replace(/^\d*\-/, '');
    this.patternDisplayName = this.patternName.split('-').reduce(function(val, working){
      return val.charAt(0).toUpperCase() + val.slice(1) + ' ' + working.charAt(0).toUpperCase() + working.slice(1);
    }, '').trim(); //this is the display name for the ui. strip numeric + hyphen prefixes
    this.patternLink = this.name + '/' + this.name + '.html';
    this.patternGroup = this.name.substring(this.name.indexOf('-') + 1, this.name.indexOf('-', 4) + 1 - this.name.indexOf('-') + 1);
    this.patternSubGroup = subdir.substring(subdir.indexOf('/') + 4);
    this.flatPatternPath = subdir.replace(/[\/\\]/g, '-');
    this.key = this.patternGroup + '-' + this.patternName;
    this.template = '';
    this.patternPartial = '';
    this.lineage = [];
    this.lineageIndex = [];
    this.lineageR = [];
    this.lineageRIndex = [];
    this.isPseudoPattern = false;
    this.engine = patternEngines.getEngineForPattern(this);
  };

  // oPattern methods

  // render method on oPatterns; this acts as a proxy for the PatternEngine's
  // render function
  oPattern.prototype.render = function (data, partials) {
    if (this.isPseudoPattern) {
      console.log(this.name + ' is a pseudo-pattern');
    } else {
      console.log('this is NOT a pseudo-pattern');
    }
    // console.log('this does ' + (this.template ? '' : 'NOT ') + 'have template');
    // console.log('this does ' + (this.extendedTemplate ? '' : 'NOT ') + 'have extendedTemplate');

    return this.engine.renderPattern(this.extendedTemplate, data, partials);
  };
{'fraction_non_alphanumeric': 0.17542101042502004, 'fraction_numerical': 0.007217321571772253, 'mean_word_length': 3.2824034334763947, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4859818', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1578, 'n_words': 357}