From e2ea148e389cc00e58d2032ff429486b47390df1 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 6 Mar 2014 13:32:32 -0500 Subject: [PATCH] FEATURE: Allow `customHTML` helper to resolve to a template if it exists. --- .../admin/templates/version_checks.js.handlebars | 1 + .../discourse/helpers/application_helpers.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/admin/templates/version_checks.js.handlebars b/app/assets/javascripts/admin/templates/version_checks.js.handlebars index 13055a3fe7d..71fc9b65753 100644 --- a/app/assets/javascripts/admin/templates/version_checks.js.handlebars +++ b/app/assets/javascripts/admin/templates/version_checks.js.handlebars @@ -2,6 +2,7 @@
+ {{customHTML 'upgrade-header'}} diff --git a/app/assets/javascripts/discourse/helpers/application_helpers.js b/app/assets/javascripts/discourse/helpers/application_helpers.js index db53759dfcb..54e2a6d8bc8 100644 --- a/app/assets/javascripts/discourse/helpers/application_helpers.js +++ b/app/assets/javascripts/discourse/helpers/application_helpers.js @@ -337,13 +337,21 @@ Ember.Handlebars.registerBoundHelper('date', function(dt) { }); /** - Look for custom html content using `Discourse.HTML` + Look for custom html content using `Discourse.HTML`. If none exists, look for a template + to render with that name. @method customHTML @for Handlebars **/ -Handlebars.registerHelper('customHTML', function(property) { - return Discourse.HTML.getCustomHTML(property); +Handlebars.registerHelper('customHTML', function(name, contextString, options) { + var html = Discourse.HTML.getCustomHTML(name); + if (html) { return html; } + + var container = (options || contextString).data.keywords.controller.container; + + if (container.lookup('template:' + name)) { + return Ember.Handlebars.helpers.render.apply(this, arguments); + } }); Ember.Handlebars.registerBoundHelper('humanSize', function(size) {
  {{i18n admin.dashboard.installed_version}}