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 +4 -4
- data/lib/trenni/builder.rb +7 -5
- data/lib/trenni/version.rb +1 -1
- data/spec/trenni/builder_spec.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a747f5883c700676507f8376d2ac63270cfec2b
|
4
|
+
data.tar.gz: 4ecbe4ef6a958bbb1e0ec745766dce9889c7a844
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e428ba9c8dc30bc5255781db70b4f14a8d9fa37dacf9ca231a6bc95c6a35d3b978009acc02cd63429d896fd7ed0d4d9365b7e9fab3144a7651a96f7e9aa55639
|
7
|
+
data.tar.gz: bf43fa7beff649e631ac81eeda8d78b3a2adcb9dd19467a99a6b12645572c88d247d34d0f43a003930f62bba909c79dd2a2d3801bf3117aaadeb80c2c012252b
|
data/lib/trenni/builder.rb
CHANGED
@@ -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(
|
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(
|
129
|
+
buffer << Strings::to_attribute(attribute_key, to_html(value))
|
128
130
|
end
|
129
131
|
end
|
130
132
|
|
data/lib/trenni/version.rb
CHANGED
data/spec/trenni/builder_spec.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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.
|