Module: Jekyll::Engine::Erb::Helpers
- Includes:
- ERB::Util
- Defined in:
- lib/jekyll/rendering.rb
Instance Method Summary collapse
-
#highlight(text, lang = :ruby) ⇒ Object
call-seq: highlight text => aString highlight text, lang => aString.
-
#include_file(file, local_assigns = {}) ⇒ Object
call-seq: include_file file => aString include_file file, local_assigns => aString.
Instance Method Details
#highlight(text, lang = :ruby) ⇒ Object
call-seq:
highlight text => aString
highlight text, lang => aString
Highlights text
according to lang
(defaults to Ruby).
250 251 252 253 254 255 256 |
# File 'lib/jekyll/rendering.rb', line 250 def highlight(text, lang = :ruby) if site.pygments render_pygments(text, lang) else render_codehighlighter(text, lang) end end |
#include_file(file, local_assigns = {}) ⇒ Object
call-seq:
include_file file => aString
include_file file, local_assigns => aString
Includes file file
from _includes
directory, or current directory if file
starts with ./
, rendered as ERB template. Passes optional local_assigns
on to #render.
231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/jekyll/rendering.rb', line 231 def include_file(file, local_assigns = {}) @templates ||= Hash.new { |h, k| h[k] = File.readable?(k) && File.read(k) } dir = file =~ /\A\.\// ? File.dirname(page.url) : '_includes' if template = @templates[File.join(site.source, dir, file)] render(template, local_assigns) else "[Included file `#{file}' not found in `#{dir}'.]" end end |