From 9c9a297d1fb5bec7ddbd4ef5709cb58cd2406c80 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 1 Feb 2013 08:31:12 +1100 Subject: Small refactor to make method more concise --- app/helpers/application_helper.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'app/helpers/application_helper.rb') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b9ba712a4..59d5e5114 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -54,15 +54,12 @@ module ApplicationHelper # Highlight words, also escapes HTML (other than spans that we add) def highlight_words(t, words, html = true) if html - t = h(t) - end - if html - t = highlight(t, words, '\1') + highlight(h(t), words, '\1') else - t = highlight(t, words, '*\1*') + highlight(t, words, '*\1*') end - return t end + def highlight_and_excerpt(t, words, excount, html = true) newt = excerpt(t, words[0], excount) if not newt -- cgit v1.2.3 From 9d0c70eb9b876c4d432f1f00f24dabebbf4ffee5 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Fri, 1 Feb 2013 08:34:48 +1100 Subject: Mark output of highlight_words helper as html_safe --- app/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/helpers/application_helper.rb') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 59d5e5114..42f9d30f1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -54,7 +54,7 @@ module ApplicationHelper # Highlight words, also escapes HTML (other than spans that we add) def highlight_words(t, words, html = true) if html - highlight(h(t), words, '\1') + highlight(h(t), words, '\1').html_safe else highlight(t, words, '*\1*') end -- cgit v1.2.3