motyl

Opinionated blog-aware static site generator written in Ruby
Log | Files | Refs | README | LICENSE

commit 0319a1148a8844f770864fc0233a81a917bac7cd
parent bd4d9c6c062138e6260e0dc9847dd59b88e77707
Author: Frederic Cambus <fred@statdns.com>
Date:   Tue, 13 Mar 2018 11:55:34 +0100

Use double pipe equals

Diffstat:
Msrc/motyl.rb | 8++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/motyl.rb b/src/motyl.rb @@ -57,9 +57,7 @@ def render(directory, templates, data) basename = File.basename(file, extension) data["page"] = YAML.load_file(directory + "/" + basename + ".yaml") data["page"]["content"] = Mustache.render(loadMD(directory + "/" + file), data) - if data["page"]["url"].nil? - data["page"]["url"] = basename + "/" - end + data["page"]["url"] ||= basename + "/" status("Rendering " + data["page"]["url"]) @@ -72,9 +70,7 @@ def render(directory, templates, data) # Populate category table data["page"]["categories"].each do |category| - if data["site"]["categories"][category].nil? - data["site"]["categories"][category] = [] - end + data["site"]["categories"][category] ||= [] data["site"]["categories"][category].push(data["page"]) data["page"]["categoryDisplay"].push({ "category" => category, "url" => data["site"]["categoryMap"][category]}) end