Browse files

Insert code examples into page instead of passing via javascript.

  • Loading branch information...
1 parent 7e5096a commit fa5a25c07f1a7b397bb67c50a0c3635a2099dde1 @nbeloglazov nbeloglazov committed Apr 11, 2012
View
10 app/assets/javascripts/langs.js.coffee
@@ -3,13 +3,17 @@
show: (data) ->
$ ->
codeExample = $('#code_example')
- if (data.code && codeExample.length > 0)
+ if (codeExample.length > 0)
+ code = $(codeExample).find('pre code')
+ code.parent().remove()
+ text = code.text()
+ mode = code.attr('class') || CodeMirror.DEFAULT_SYNTAX_MODE
CodeMirror(
codeExample[0],
{
- mode: data.syntax_mode || CodeMirror.DEFAULT_SYNTAX_MODE,
+ mode: mode,
theme: $.cookie(CodeMirror.COOKIE) ? 'default',
readOnly: true,
- value: data.code
+ value: text
}
)
View
1 app/controllers/languages_controller.rb
@@ -4,7 +4,6 @@ class LanguagesController < ApplicationController
def show
@lang = Language.find(params[:id])
- styx_initialize_with :syntax_mode => @lang.syntax_mode, :code => @lang.code_example
end
def buy
View
2 app/views/languages/show.html.haml
@@ -5,6 +5,8 @@
- if @lang.code_example.present?
%div#code_example
+ %pre
+ %code{ class: @lang.syntax_mode }= find_and_preserve @lang.code_example
%div.links
%p.title Useful links:

0 comments on commit fa5a25c

Please sign in to comment.