Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from dsci/master

Content type helper
  • Loading branch information...
commit 0a5ab81fcc32b3ae533b9b6a7a565d3c85e943ea 2 parents 5e9a2a4 + 197d4a9
@danhigham authored
View
13 app/helpers/admin/ace_helper.rb
@@ -2,6 +2,19 @@ module Admin::AceHelper
include Admin::NodeHelper
include Admin::ReferencesHelper
+ def content_type_for_page(page_part)
+ default_content_type = "text/html"
+ if page_part.page.nil?
+ return default_content_type
+ else
+ if page_part.page.layout.respond_to?(:content_type)
+ return page_part.page.layout.content_type
+ else
+ return default_content_type
+ end
+ end
+ end
+
def init_script(tag_id, text_area_id, content_type, filter)
@javascripts << ["/ace/src/ace.js", "/ace/src/ace-utils.js", "/ace/src/theme-twilight.js", "/ace/src/theme-textmate.js", "/ace/src/mode-html.js", "/ace/src/mode-css.js", "/ace/src/mode-coffee.js", "/ace/src/mode-javascript.js"]
@stylesheets << ["/ace/src/ace-resize.css"]
View
2  app/views/admin/page_parts/_page_part.html.haml
@@ -1,7 +1,7 @@
-ActionView::Base.send :include, Admin::AceHelper
-filter = page_part.filter
--layout = page_part.page.nil? ? "text/html" : page_part.page.layout.content_type
+-layout = content_type_for_page(page_part)
=init_script("editor_part_#{page_part.name.to_slug}_content", "part_#{page_part.name.to_slug}_content", layout, filter)
Please sign in to comment.
Something went wrong with that request. Please try again.