Add template support
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#= require ace/mode-coffee
|
||||
#= require ace/mode-handlebars
|
||||
#= require ace/mode-yaml
|
||||
#= require ace/mode-haml
|
||||
#= require tinymce-jquery
|
||||
#= require_directory .
|
||||
#= require_self
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@ class HtmlEdit
|
||||
#ACE
|
||||
$('.html-content').each (i, el)->
|
||||
text_field = $(el)
|
||||
template_field = $("##{text_field.attr('id')}_template")
|
||||
ace_div = $('<div></div>').addClass('ace-div')
|
||||
text_field.after ace_div
|
||||
ace_div.css
|
||||
@@ -10,12 +11,24 @@ class HtmlEdit
|
||||
height: '600px'
|
||||
editor = ace.edit(ace_div.get(0))
|
||||
editor.setTheme 'ace/theme/monokai'
|
||||
if template_field.length
|
||||
editor.setValue template_field.val(), -1
|
||||
editor.getSession().setMode 'ace/mode/haml'
|
||||
else
|
||||
editor.setValue text_field.val(), -1
|
||||
editor.getSession().setMode 'ace/mode/handlebars'
|
||||
editor.getSession().setTabSize(2)
|
||||
editor.getSession().setUseSoftTabs(true)
|
||||
editor.getSession().on 'change', (e)->
|
||||
text_field.val(editor.getValue()).change()
|
||||
value = editor.getValue()
|
||||
if template_field.length
|
||||
try
|
||||
template = Emblem.compile(Handlebars, value)
|
||||
result_value = template(page_vars)
|
||||
template_field.val value
|
||||
text_field.val result_value
|
||||
else
|
||||
text_field.val value
|
||||
text_field.hide()
|
||||
#ace_div.hide()
|
||||
template_field.hide()
|
||||
@html_edit = new HtmlEdit()
|
||||
|
||||
@@ -27,8 +27,8 @@ javascript:
|
||||
.form-field= f.select :locale, Page.locales
|
||||
.form-row
|
||||
= f.label :body
|
||||
br
|
||||
= f.text_area :body, rows: 30, cols: 80, class: 'html-content'
|
||||
= f.text_area :body_template
|
||||
= collapsible_content 'Sidebar' do
|
||||
.field
|
||||
= f.label :sidebar
|
||||
|
||||
@@ -11,8 +11,11 @@ module Cmtool
|
||||
klass.property :menu_text
|
||||
klass.property :title
|
||||
klass.property :body
|
||||
klass.property :footer
|
||||
klass.property :body_template
|
||||
klass.property :sidebar
|
||||
klass.property :sidebar_template
|
||||
klass.property :footer
|
||||
klass.property :footer_template
|
||||
klass.property :wysiwyg, type: :boolean, default: false
|
||||
klass.property :priority, type: Float, default: 0.5
|
||||
klass.property :active, type: :boolean, default: true
|
||||
|
||||
Reference in New Issue
Block a user