trenni 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c17ddcecd402c971c098d70f430380b664cd581e
4
- data.tar.gz: b1270c75070860bb91008a08c4be7c58f1eaa5e2
3
+ metadata.gz: 0a747f5883c700676507f8376d2ac63270cfec2b
4
+ data.tar.gz: 4ecbe4ef6a958bbb1e0ec745766dce9889c7a844
5
5
  SHA512:
6
- metadata.gz: 0c7387728d78797608f8369bd617b86edcaa23bd2663ef1b854917515a09bc0f9888f357267378620af854f469007e5fea9928374477a57025e34c0950fc3efc
7
- data.tar.gz: 46684a95b5e07c3f522cba2f04db9ca1320c2edcb205d361156014fa9789b6332a014694e8dabb4fe2ce7a32ee56795d4b0be8b1f7dc4a2d7f52f974530bd818
6
+ metadata.gz: e428ba9c8dc30bc5255781db70b4f14a8d9fa37dacf9ca231a6bc95c6a35d3b978009acc02cd63429d896fd7ed0d4d9365b7e9fab3144a7651a96f7e9aa55639
7
+ data.tar.gz: bf43fa7beff649e631ac81eeda8d78b3a2adcb9dd19467a99a6b12645572c88d247d34d0f43a003930f62bba909c79dd2a2d3801bf3117aaadeb80c2c012252b
@@ -117,14 +117,16 @@ module Trenni
117
117
  end
118
118
 
119
119
  # Convert a set of attributes into a string suitable for use within a <tag>.
120
- def tag_attributes(attributes)
121
- buffer = []
122
-
120
+ def tag_attributes(attributes, buffer = [], prefix = nil)
123
121
  attributes.each do |key, value|
122
+ attribute_key = prefix ? "#{prefix}-#{key}" : key
123
+
124
124
  if value == true
125
- buffer << Strings::to_simple_attribute(key, @strict)
125
+ buffer << Strings::to_simple_attribute(attribute_key, @strict)
126
+ elsif value.is_a? Hash
127
+ tag_attributes(value, buffer, attribute_key)
126
128
  elsif value
127
- buffer << Strings::to_attribute(key, to_html(value))
129
+ buffer << Strings::to_attribute(attribute_key, to_html(value))
128
130
  end
129
131
  end
130
132
 
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Trenni
22
- VERSION = "1.6.0"
22
+ VERSION = "1.7.0"
23
23
  end
@@ -23,6 +23,14 @@
23
23
  require 'trenni'
24
24
 
25
25
  module Trenni::BuilderSpec
26
+ describe 'Trenni::Builder#tag_attributes' do
27
+ subject {Trenni::Builder.new}
28
+
29
+ it "should format nested attributes" do
30
+ expect(subject.tag_attributes(data: {id: 10})).to be == ' data-id="10"'
31
+ end
32
+ end
33
+
26
34
  describe 'Trenni::Builder#fragment' do
27
35
  let(:builder) {Trenni::Builder.new}
28
36
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trenni
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-13 00:00:00.000000000 Z
11
+ date: 2016-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.5.2
110
+ rubygems_version: 2.5.1
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: A fast native templating system that compiles directly to Ruby code.