Sha256: b5e5e2ed222220a3308589238c5b184c31ab8bc39dfafe2cf2f23d1582aac3ba

Contents?: true

Size: 690 Bytes

Versions: 1

Compression:

Stored size: 690 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

1 entries across 1 versions & 1 rubygems

Version Path
poirot-0.1.0 vendor/assets/javascripts/poirot/poirot.js