sinatra-partial 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.markdown CHANGED
@@ -1,3 +1,13 @@
1
+ ## v0.4.0 ##
2
+
3
+ 10th of December 2012
4
+
5
+ * Fixed example in README, re issue#4, thanks to [@moollaza](https://github.com/moollaza) for pointing it out.
6
+ * better handling of paths, which helps fix a (hopefully rare) error when a dot is in the path.
7
+
8
+ ----
9
+
10
+
1
11
  ## v0.3.2 ##
2
12
 
3
13
  23rd of August 2012
data/README.markdown CHANGED
@@ -163,8 +163,11 @@ Here's how to use a collection, in this case to render a menu:
163
163
  = partial :menu_item, collection: menu
164
164
 
165
165
  -# menu_item.haml
166
+ - display_name, url = menu_item
166
167
  - atts ||= {}
167
- - atts[:active] = {class: "active" } if request.url == menu_item.last
168
+ -# set the class of the list item for the current page to 'active'
169
+ - (atts[:class] = atts[:class].nil? ? "active" : "#{atts[:class]} active") if request.url == url
170
+
168
171
  %li{ atts }
169
172
  %a{ class: "nav", href: menu_item.last }
170
173
  = menu_item.first
@@ -14,9 +14,10 @@ module Sinatra
14
14
  # param [true,false,nil] underscores Defaults to false
15
15
  def self.partial_expand_path(partial_path, underscores=false)
16
16
  underscores ||= false
17
- dirs, base = [File.dirname(partial_path),File.basename(partial_path)]
17
+ dirs, base = File.dirname(partial_path), File.basename(partial_path)
18
18
  base.insert(0, "_") if underscores
19
- File.join(dirs, base).to_sym
19
+ xs = dirs == "." ? [base] : [dirs, base]
20
+ File.join(xs).to_sym
20
21
  end
21
22
 
22
23
  # This takes the name of the local from the template's name, and corrects local by removing leading underscore if it's there.
@@ -71,6 +72,8 @@ module Sinatra
71
72
  buffer << self.method(engine).call(template, options.merge(:locals => new_locals))
72
73
  end.join("\n")
73
74
  else
75
+ # TODO benchmark this and see if caching the method
76
+ # speeds things up
74
77
  self.method(engine).call(template, options)
75
78
  end
76
79
  end
@@ -1,5 +1,5 @@
1
1
  module Sinatra
2
2
  module Partial
3
- VERSION = "0.3.2"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -11,12 +11,12 @@ describe "partial_expand_path" do
11
11
  context "Given a single word" do
12
12
  let(:partial_path) { "news" }
13
13
  context "and underscores is set to false." do
14
- let(:expected) { :"./news" }
14
+ let(:expected) { :news }
15
15
  let(:underscores) { false }
16
16
  it { should == expected }
17
17
  end
18
18
  context "and underscores is set to true." do
19
- let(:expected) { :"./_news" }
19
+ let(:expected) { :"_news" }
20
20
  let(:underscores) { true }
21
21
  it { should == expected }
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-partial
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-08-23 00:00:00.000000000 Z
14
+ date: 2012-12-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sinatra