m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Chrzanowski <m@m-chrzan.xyz>2021-03-27 22:21:45 +0100
committerMarcin Chrzanowski <m@m-chrzan.xyz>2021-03-27 22:21:45 +0100
commita6b11a3bf098c673b7f1142be60f04a00885f5a7 (patch)
treea7ffb48467763708a076b6b9fe0ca6e590e1116e
parent734687cad0d439cc90551be2e82bdd61280a07d6 (diff)
Use - trimming in ERB
-rw-r--r--lib/templated.rb4
-rw-r--r--src/blog.html.erb4
-rw-r--r--src/index.html.erb4
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/templated.rb b/lib/templated.rb
index 9323903..a39990d 100644
--- a/lib/templated.rb
+++ b/lib/templated.rb
@@ -1,5 +1,5 @@
def template
- ERB.new(File.read(src 'template.html.erb'))
+ ERB.new(File.read(src 'template.html.erb'), trim_mode: '-')
end
def write_templated_file content_filename, options
@@ -14,7 +14,7 @@ def write_erb erb_filename
end
def write_templated_erb erb_filename, options
- content = ERB.new(File.read(src erb_filename)).result
+ content = ERB.new(File.read(src erb_filename), trim_mode: '-').result
cut_filename = erb_filename.sub /\.erb$/, ''
write_templated content, cut_filename, options
end
diff --git a/src/blog.html.erb b/src/blog.html.erb
index 7fb308e..c5ccee2 100644
--- a/src/blog.html.erb
+++ b/src/blog.html.erb
@@ -2,9 +2,9 @@
Subscribe with <a href='<%= path_to 'rss' %>'>RSS</a>
</p>
<ul>
-<% posts.each do |post| %>
+<% posts.each do |post| -%>
<li>
<a href=<%= path_to post['id'] %>><%= post['title'] %></a> <%= format_date post['date'] %>
</li>
-<% end %>
+<% end -%>
</ul>
diff --git a/src/index.html.erb b/src/index.html.erb
index 536b15a..414b201 100644
--- a/src/index.html.erb
+++ b/src/index.html.erb
@@ -8,11 +8,11 @@
<h2>Recent posts <a style='font-size: 18px;' href='<%= path_to 'rss' %>'>(RSS)</a>:</h2>
<ul>
-<% posts.take(5).each do |post| %>
+<% posts.take(5).each do |post| -%>
<li>
<a href='<%= path_to post['id'] %>'><%= post['title'] %></a> <%= format_date post['date'] %>
</li>
-<% end %>
+<% end -%>
</ul>
<hr />