Permalink
Browse files

Use partial method to render shared partials.

  • Loading branch information...
1 parent f8fb2ff commit a28c232adcd6cd3154b0e445548a53411c994dd6 @floere floere committed Dec 25, 2013
Showing with 13 additions and 45 deletions.
  1. +10 −4 config.rb
  2. +0 −37 lib/shared_layouts.rb
  3. +3 −4 source/layouts/layout.slim
View
@@ -1,5 +1,3 @@
-require "lib/shared_layouts.rb"
-
set :encoding, 'utf-8'
set :relative_links, true
@@ -19,8 +17,6 @@
activate :automatic_image_sizes
activate :rouge_syntax
-activate :shared_layouts
-
configure :development do
activate :livereload
end
@@ -32,4 +28,14 @@
sprockets.append_path "../shared/fonts"
sprockets.append_path "../shared/includes"
sprockets.append_path "../shared/sass"
+end
+
+helpers do
+
+ def shared_partial(*sources)
+ sources.inject([]) do |combined, source|
+ combined << partial("../shared/includes/#{source}")
+ end.join
+ end
+
end
View
@@ -1,37 +0,0 @@
-require 'tilt'
-require 'slim'
-
-# Require core library
-require "middleman-core"
-require "middleman-core/core_extensions"
-
-# Essentially a way of getting partials from the shared folder
-# TODO:there may be a more native way of doing this in middleman using partials?
-
-module SharedLayouts
- class << self
-
- def registered(app, options={})
- app.helpers LayoutTagHelper
- $APP = app
- end
- alias :included :registered
-
- end
-end
-
-module LayoutTagHelper
-
- def shared_layout(*sources)
- current_dir = File.dirname(File.expand_path(__FILE__))
- shared_include = current_dir + "/../shared/includes/" + sources.first + ".slim"
- host_object = sources.count > 1 ? sources[1] : nil
-
- template = Tilt::new shared_include
- template.render($APP, :home => true, :host => host_object )
- end
-end
-
-::Middleman::Extensions.register(:shared_layouts) do
- ::SharedLayouts
-end
@@ -3,17 +3,16 @@ html lang="en-en"
head
title = "CocoaPods.org - The Dependency Manager for Objective C."
- == shared_layout("header_meta")
- == shared_layout("favicons")
+ == shared_partial("header_meta", "favicons")
== stylesheet_link_tag "app.css"
== javascript_include_tag "application.js"
body
- == shared_layout("header", self)
+ == shared_partial("header")
== yield
.clearfix
- == shared_layout("footer")
+ == shared_partial("footer")

0 comments on commit a28c232

Please sign in to comment.