diff options
author | Mark Chao <mchao@gitlab.com> | 2018-09-06 12:48:57 +0300 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-10-30 10:44:55 +0300 |
commit | 32f9cf8ce3dd337bf3b1683c5872171c253f0d27 (patch) | |
tree | da6f8077d458283ae1da56cbc9e282c87cdeba0a /app/presenters/blob_presenter.rb | |
parent | 6580de78bb52323fcafaaf4d2e770590e4f1c586 (diff) |
Add BlobPresenter for highlighting
Force FoundBlob to use BlobPresenter
Diffstat (limited to 'app/presenters/blob_presenter.rb')
-rw-r--r-- | app/presenters/blob_presenter.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/presenters/blob_presenter.rb b/app/presenters/blob_presenter.rb new file mode 100644 index 00000000000..2bca413876c --- /dev/null +++ b/app/presenters/blob_presenter.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class BlobPresenter < Gitlab::View::Presenter::Simple + presents :blob + + def highlight(plain: nil) + Gitlab::Highlight.highlight( + blob.path, + blob.data, + language: blob.language_from_gitattributes, + plain: (plain || blob.no_highlighting?) + ) + end +end |