Skip to content

Instantly share code, notes, and snippets.

View jdlich's full-sized avatar

Jacob Lichner jdlich

View GitHub Profile
require 'home.rb'
#
# Default
#
include Nanoc3::Helpers::Rendering
include Nanoc3::Helpers::Capturing
#
# Custom
class Home
require 'yaml'
def initialize item
@item = item
attributes = File.expand_path('content' + @item.identifier.gsub(/\/$/,'') + '.yaml')
attributes = File.open(attributes) { |a| YAML::load(a) }.keys
attributes.map do |attribute|
include Nanoc3::Helpers::Formatting
# load rake tasks
Dir['tasks/**/*.rake'].sort.each { |rakefile| load rakefile }
require Nanoc3::Helpers::Formatting
# load rake tasks
Dir['tasks/**/*.rake'].sort.each { |rakefile| load rakefile }
require 'nanoc3'
include Nanoc3::Helpers::Formatting
# load rake tasks
Dir['tasks/**/*.rake'].sort.each { |rakefile| load rakefile }
<% for home in homes do %>
<div>
<a href="<%= home.path %>">
<img src="<%= home.image_folder %>/thumbnail.jpg" alt="<%= home.thumbnail_alt_text %>" />
</a>
</div>
<% end %>
<% for home in homes do %>
<div>
<a href="<%= home.path %>">
<img src="<%= home.image_folder %>/thumbnail.jpg" alt="<%= home.thumbnail_alt_text %>" />
</a>
</div>
<% end %>
# encoding: utf-8
desc 'Removes all stray files from the output directory'
task :clean_all do
puts '=== Removing stray files from output directory…'
# Get static files
static_files = Dir['assets/**/*'].select { |f| File.file?(f) }.map { |f| f.sub(/^assets\//, 'output/') }
# Get compiled files
---
---
/*
Typography
-------------------------------------------------------------- */
def initialize item
# set the item instance variable
@item = item
# grab the item's attributes from its yaml file
attributes = File.expand_path('content' + item.identifier.gsub(/\/$/,'') + '.yaml')
# load the yaml data into a hash and grab just the attribute
# names, not the values
attributes = File.open(attributes) { |a| YAML::load(a) }.keys