Module: Gitdocs::RenderingHelper
- Defined in:
- lib/gitdocs/rendering_helper.rb
Defined Under Namespace
Classes: CodeRayify
Instance Method Summary collapse
Instance Method Details
#file_content_render(pathname) ⇒ nil, String
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gitdocs/rendering_helper.rb', line 16 def file_content_render(pathname) return unless pathname tilt = Tilt.new( pathname, 1, # line number fenced_code_blocks: true, renderer: CodeRayify.new(filter_html: true, hard_wrap: true) ) %(<div class="tilt">#{tilt.render}</div>) rescue LoadError, RuntimeError # No tilt support if path.text? code_ray = CodeRay.scan_file(pathname) %(<pre class="CodeRay">#{code_ray.encode(:html)}</pre>) else %(<embed class="inline-file" src="#{request.path_info}?mode=raw"></embed>) end end |