Sha256: 1bbde7c4f175aafc95339fb562d38c9cb4209164b66ff71c885055d6c3fee0cb
Contents?: true
Size: 742 Bytes
Versions: 2
Compression:
Stored size: 742 Bytes
Contents
module CodeHighlight class MainController < Volt::ModelController # Since the contents of the <code> tag will be replaced by highlight.js, # we can't use a content binding, instead we use jquery to insert the # html, and then highlight it after each insert. We use a .watch! to # update the code. def update_code html = yield_html `$(#{code_tag}).html(html);` highlight end def index_ready @watcher = -> { update_code }.watch! end def before_index_remove @watcher.stop if @watcher end def code_tag first_element end def highlight `hljs.configure({useBR: true});` block = code_tag `hljs.highlightBlock(block);` end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
volt-code_highlight-0.2.0 | app/code_highlight/controllers/main_controller.rb |
volt-code_highlight-0.1.0 | app/code_highlight/controllers/main_controller.rb |