Added module for helper functions; added helper for formatting date consistently
This commit is contained in:
parent
291db231d5
commit
691e2e9b1e
8
src/helpers.rb
Normal file
8
src/helpers.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module Helpers
|
||||||
|
|
||||||
|
def date_format(date)
|
||||||
|
dt = date.to_datetime
|
||||||
|
return dt.strftime('%B %d, %Y @ %I:%M:%S %p %Z')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -15,6 +15,10 @@ class GameData < Sinatra::Base
|
|||||||
enable :static
|
enable :static
|
||||||
set :public_folder, File.join(__dir__, '/../public')
|
set :public_folder, File.join(__dir__, '/../public')
|
||||||
|
|
||||||
|
# Register view helpers
|
||||||
|
require_relative 'helpers'
|
||||||
|
helpers Helpers
|
||||||
|
|
||||||
# Set up our view engine
|
# Set up our view engine
|
||||||
set :views, File.join(settings.root, '/../views')
|
set :views, File.join(settings.root, '/../views')
|
||||||
end
|
end
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= b.name %></td>
|
<td><%= b.name %></td>
|
||||||
<td><%= b.scoring %></td>
|
<td><%= b.scoring %></td>
|
||||||
<td><%= b.created_at %></td>
|
<td><%= date_format(b.created_at) %></td>
|
||||||
<td><%= b.updated_at %></td>
|
<td><%= date_format(b.updated_at) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= h.name %></td>
|
<td><%= h.name %></td>
|
||||||
<td><%= h.type %></td>
|
<td><%= h.type %></td>
|
||||||
<td><%= h.created_at %></td>
|
<td><%= date_format(h.created_at) %></td>
|
||||||
<td><%= h.updated_at %></td>
|
<td><%= date_format(h.updated_at) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Loading…
Reference in New Issue
Block a user