All files / mobile.startup Section.js

100% Statements 16/16
100% Branches 6/6
100% Functions 2/2
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 451x 1x 1x                     4x 4x 4x 4x 4x 4x 4x 4x 4x 4x     1x                                   1x  
var util = require( './util.js' ),
	mfExtend = require( './mfExtend' ),
	View = require( './View' );
 
/**
 * Builds a section of a page
 *
 * @class Section
 * @extends View
 *
 * @param {Object} options Configuration options
 */
function Section( options ) {
	var self = this;
	options.tag = 'h' + options.level;
	this.line = options.line;
	this.text = options.text;
	this.hasReferences = options.hasReferences || false;
	this.id = options.id || null;
	this.anchor = options.anchor;
	this.subsections = [];
	( options.subsections || [] ).forEach( ( section ) => self.subsections.push( new Section( section ) ) );
	View.call( this, options );
}
 
mfExtend( Section, View, {
	template: util.template( `
<h{{level}} id="{{anchor}}">{{{line}}}</h{{level}}>
{{{text}}}
	` ),
	/**
	 * @memberof Section
	 * @instance
	 * @mixes View#defaults
	 * @property {Object} defaults Default options hash.
	 * @property {string} defaults.text Section text.
	 */
	defaults: {
		line: undefined,
		text: ''
	}
} );
 
module.exports = Section;