'use strict';

var assert = require('assert')
  , fs = require('fs')
  , path = require('path')
  , handlebars = require('handlebars')
  , cssInjector = require('../wrappers/cssInjector')

var assetsPath = __dirname + '/../config/assets'

class PopupPresenter {
  constructor(config) {
    assert.equal(typeof (config), 'object', '\'config\' arg must be an object')

    var templatePath = path.join(assetsPath, 'templates', config.template)
    this.template = handlebars.compile(fs.readFileSync(templatePath, 'utf-8'))

    var cssPath = path.join(assetsPath, 'css', config.css)
    cssInjector(fs.readFileSync(cssPath, 'utf-8'))
  }

  present(properties) {
    return this.template(properties)
  }
}

module.exports = (config) => new PopupPresenter(config)

@@ -236,30 +236,353 @@
 s'%0A%0A
-class PopupPresenter %7B
+/**%0A * Class to handle css and html template for a layers popup generation%0A * Css is injected into the dom and a function is returned via 'present'%0A * that can be used by the map on a per geosjon feature basis%0A */%0Aclass PopupPresenter %7B%0A%0A  /**%0A   * Creates a template function from config and injects given layer css%0A   * file into the dom%0A   */
 %0A  c
@@ -959,29 +959,286 @@
 %0A%0A  
-present(properties) %7B
+/**%0A   * Renders properties into a template string using template function%0A   * created in the constructor%0A   * @param %7Bobject%7D properties%0A   * @return %7Bstring%7D%0A   */%0A  present(properties) %7B%0A    assert.equal(typeof (properties), 'object', '%5C'properties%5C' arg must be an object')
 %0A   

Update popupPresenter, harden + document interface