Return early from markdown and gfm when text is empty

This commit is contained in:
Robert Speicher 2015-09-03 16:38:35 -04:00
parent e5d89c1084
commit 4bd92e681e
3 changed files with 6 additions and 4 deletions

View File

@ -45,6 +45,8 @@ module GitlabMarkdownHelper
end
def markdown(text, context = {})
return unless text.present?
context.merge!(
path: @path,
project: @project,
@ -59,6 +61,8 @@ module GitlabMarkdownHelper
# TODO (rspeicher): Remove all usages of this helper and just call `markdown`
# with a custom pipeline depending on the content being rendered
def gfm(text, options = {})
return unless text.present?
options.merge!(
path: @path,
project: @project,

View File

@ -1,3 +1,2 @@
%div{xmlns: "http://www.w3.org/1999/xhtml"}
- if issue.description.present?
= markdown(issue.description, xhtml: true, reference_only_path: false, project: issue.project)
= markdown(issue.description, xhtml: true, reference_only_path: false, project: issue.project)

View File

@ -1,3 +1,2 @@
%div{xmlns: "http://www.w3.org/1999/xhtml"}
- if merge_request.description.present?
= markdown(merge_request.description, xhtml: true, reference_only_path: false, project: merge_request.project)
= markdown(merge_request.description, xhtml: true, reference_only_path: false, project: merge_request.project)