'use strict';

var assert       = require('assert')
var handlebars   = require('handlebars')
var cssInjector  = require('../wrappers/cssInjector')
var assetManager = require('./assetManager')

/**
 * Class to handle css and html template for a layers popup generation
 * Css is injected into the dom and a function is returned via 'present'
 * that can be used by the map on a per geosjon feature basis
 */
class PopupPresenter {

  /**
   * Creates a template function from config and injects given layer css
   * file into the dom
   */
  constructor(config) {
    assert.equal(typeof (config), 'object', '\'config\' arg must be an object')

    var templateContent = assetManager.assets.templates[config.template]
    this.template = handlebars.compile(templateContent)

    var css = assetManager.assets.css[config.css]
    cssInjector(css)
  }

  /**
   * Renders properties into a template string using template function
   * created in the constructor
   * @param {object} properties
   * @return {string}
   */
  present(properties) {
    assert.equal(typeof (properties), 'object', '\'properties\' arg must be an object')
    return this.template(properties)
  }
}

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

'use strict';

var assert       = require('assert')
var handlebars   = require('handlebars')
var cssInjector  = require('../wrappers/cssInjector')
var assetManager = require('./assetManager')()

/**
 * Class to handle css and html template for a layers popup generation
 * Css is injected into the dom and a function is returned via 'present'
 * that can be used by the map on a per geosjon feature basis
 */
class PopupPresenter {

  /**
   * Creates a template function from config and injects given layer css
   * file into the dom
   */
  constructor(config) {
    assert.equal(typeof (config), 'object', '\'config\' arg must be an object')

    var templateContent = assetManager.assets.templates[config.template]
    this.template = handlebars.compile(templateContent)

    var css = assetManager.assets.css[config.css]
    cssInjector(css)
  }

  /**
   * Renders properties into a template string using template function
   * created in the constructor
   * @param {object} properties
   * @return {string}
   */
  present(properties) {
    assert.equal(typeof (properties), 'object', '\'properties\' arg must be an object')
    return this.template(properties)
  }
}

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

Fix assetManager not being instantiated
Fix assetManager not being instantiated
