Sha256: 058d44050b125bb70b9d76d7ed48f0385778541a430da73ac3ccc5950403f542

Contents?: true

Size: 693 Bytes

Versions: 2

Compression:

Stored size: 693 Bytes

Contents

var poirot = (function ($) {

  var viewFactory = function (template, partials) {
    return function (data) {
      return $(Mustache.to_html(template, data, partials))
    }
  }

  var poirot = {
    _partials: {},
    _viewFactory: viewFactory
  }

  $(document).ready(function () {
    $('script[type="text/mustache"]').each(function () {
      var template = $(this).text()
      var methodName = this.id.replace(/-([a-z])/g, function (str) {
        return str.replace("-", "").toUpperCase()
      }).replace("Template", "")

      poirot._partials[methodName] = template

      poirot[methodName] = poirot._viewFactory(template, poirot._partials)
    })
  })

  return poirot
})(jQuery)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
poirot-0.2.1 vendor/assets/javascripts/poirot-base/poirot.js
poirot-0.2.0 vendor/assets/javascripts/poirot-base/poirot.js