From 8982f8845abbb9e378b059ccafc3f1c76da60779 Mon Sep 17 00:00:00 2001 From: Micah Geisel Date: Wed, 17 Apr 2013 12:48:09 -0700 Subject: [PATCH] got something working with partial helper. --- lib/spar/helpers.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/spar/helpers.rb b/lib/spar/helpers.rb index 8c48672..d600527 100644 --- a/lib/spar/helpers.rb +++ b/lib/spar/helpers.rb @@ -22,6 +22,16 @@ def append_features(context) # :nodoc: end + def partial path + segments = path.split("/") + segments[-1] = "_#{segments[-1]}.html" # assume html content-type and leading underscore + segments.unshift(".") # force relative path + partial_path = self.resolve(segments.join("/")).to_s # resolve path with sprockets lookup context + + template = Tilt.new(partial_path) + template.render + end + def path_to(asset_name, options={}) asset_name = asset_name.logical_path if asset_name.respond_to?(:logical_path) path = Helpers.paths.compute_public_path(asset_name, options.merge(:body => true))