           tplDef = _getTemplateDefinition name, ref, widgetName, app.core.dom.find
           if tplDef
             ret[name] = tplDef
-          else 
+          else
             undefinedTemplates.push([name, "text!#{ref}/#{name}.#{format}"])
         if undefinedTemplates.length > 0
           module.require(_.map(undefinedTemplates, (p) -> p[1]), ->

    engine.registerPartial(tplName, compiled)
    compiled

  # Handles the various priorities and locations of templates 
  _getTemplateDefinition = (name, ref, widgetName, dom)->
    path = "#{ref}/#{name}"
    tplName = [widgetName, name.replace(/^_/, '')].join("/")

    module.define path, parsed
    parsed

  module =
    global: window
    require: require
    define: define
    templateEngine: Handlebars
    getTemplateDefinition: _getTemplateDefinition
    initialize: (app) ->
      app.core.template.load = (names=[], ref, format="hbs") ->
        undefinedTemplates = []
