From 02960a0cdc29f443f4235986f86b5fb828922a72 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Sun, 10 Jun 2012 15:16:12 +0200 Subject: [PATCH] Properly indent whole multiline comment in email notification --- app/helpers/application_helper.rb | 4 ++++ app/mailers/user_mailer.rb | 1 + app/views/user_mailer/new_comment_email.text.erb | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 40a6548..2e27653 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -21,4 +21,8 @@ module ApplicationHelper text = capture(&block) MKD_RENDERER.render(capture(&block)).html_safe end + + def indented(string, width) + string.lines.map { |l| "#{' ' * width}#{l}" }.join('') + end end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 0e6ee94..2ddaf96 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -1,5 +1,6 @@ class UserMailer < ActionMailer::Base default :from => "ascii.io " + helper :application def new_comment_email(user, comment) @comment = comment diff --git a/app/views/user_mailer/new_comment_email.text.erb b/app/views/user_mailer/new_comment_email.text.erb index 559cb66..96af75b 100644 --- a/app/views/user_mailer/new_comment_email.text.erb +++ b/app/views/user_mailer/new_comment_email.text.erb @@ -2,7 +2,7 @@ Howdy! ~<%= @author.nickname %> (<%= profile_url(@author) %>) commented on your asciicast "<%= @asciicast.smart_title %>": - <%= @comment.body %> +<%= indented @comment.body, 4 %> --- http://ascii.io/