Module: Simplabs::Highlight::ViewMethods
- Defined in:
- lib/simplabs/highlight.rb
Overview
View Helpers for using Simplabs::Highlight in Ruby on Rails templates.
Instance Method Summary collapse
-
#highlight_code(language, code = nil) { ... } ⇒ String
Highlights the passed
code
with the appropriate rules according to the specifiedlanguage
.
Instance Method Details
#highlight_code(language, code = nil) { ... } ⇒ String
Highlights the passed code
with the appropriate rules according to the specified language
. The code can be specified either as a string or provided in a block.
162 163 164 165 166 167 |
# File 'lib/simplabs/highlight.rb', line 162 def highlight_code(language, code = nil, &block) raise ArgumentError.new('Either pass a srting containing the code or a block, not both!') if !code.nil? && block_given? raise ArgumentError.new('Pass a srting containing the code or a block!') if code.nil? && !block_given? code ||= yield Simplabs::Highlight.highlight(language, code) end |