Code coverage report for lib/docview.js

Statements: 19.35% (6 / 31)      Branches: 0% (0 / 14)      Functions: 0% (0 / 4)      Lines: 19.35% (6 / 31)      Ignored: none     

All files » lib/ » docview.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78              1 1 1                     1                                   1                                                                           1  
/* global YUI */
 
/**
 * The firedoc module
 * @module firedoc
 */
 
const _ = require('underscore');
const path = require('path');
const Handlebars = require('handlebars');
 
/**
 * View class borrowed from [Selleck](https://github.com/rgrove/selleck)  
 * The view class is a **`handlebars`** template helper.
 *
 * @class DocView
 * @constructor
 * @param {Object} data Meta data to use in this template
 * @param {String} templateName The name of the template file to render.
 **/
function DocView (data, templateName, cwd) {
  this.templateName = templateName;
  this.cwd = path.join(cwd || '');
  this.assets = path.join(cwd || '', 'assets');
  _.extend(this, data);
 
  // register helpers
  var self = this;
  Handlebars.registerHelper('relink', function (item, options) {
    item = item || '';
    if (self.project.local) {
      return '//' + self.project.root + '/' + item;
    } else {
      return self.project.baseurl + '/' + item;
    }
  });
}
 
DocView.prototype = {
  /**
   * **Mustache** `lambda` method for setting the HTML title
   * @method htmlTitle
   */
  htmlTitle: function () {
    var name = this.name;
    var title = name;
    try {
      if (title) {
        if (this.project.name) {
          title += ' - ' + this.project.name;
        }
      } else {
        title = this.project.name;
      }
    } catch (e) {}
    return title;
  },
 
  /**
   * **Mustache** `lambda` method for setting the title
   * @method title
   */
  title: function () {
    var name = this.name;
    var title = name;
    try {
      title = this.project.name;
      if (name) {
        title += ': ' + name;
      }
    } catch (e) {}
    return title;
  }
 
};
 
exports.DocView = DocView;