fira 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,44 +26,45 @@ module Fira
26
26
  #find and replace fira ID attributes
27
27
  result = no_quotes.sub(ID_REGEX, ' id="\1"')
28
28
 
29
- #find fira class attributes
30
- classes = result.scan(CLASS_REGEX)
29
+ #find and replace fira class attributes
30
+ result = parse_classes(result)
31
31
 
32
- if ! classes.empty?
32
+ #add back in the quotes
33
+ output += insert_quotes(quotes, result)
33
34
 
34
- #build an HTML class attribute
35
- att = 'class="'
35
+ #find and replace fira data attributes
36
+ output = output.gsub("\$", "data-")
36
37
 
37
- classes.each do |cl|
38
- att += " #{cl[0]}"
39
- end
38
+ else
39
+ output += token
40
+ end
41
+ end
40
42
 
41
- att += '"'
43
+ return output
44
+ end
42
45
 
43
- #remove the space before the first class
44
- att = att.sub(/class=" /, ' class="')
46
+ def parse_classes(text)
47
+ #find fira class attributes
48
+ classes = text.scan(CLASS_REGEX)
45
49
 
46
- #remove the first fira class attribute
47
- new_tag = result.sub(CLASS_REGEX, att)
50
+ if classes.empty?
51
+ return text
52
+ end
48
53
 
49
- #remove the rest of the fira class attributes
50
- final_result = new_tag.gsub(CLASS_REGEX, "")
54
+ #build an HTML class attribute
55
+ att = 'class="'
51
56
 
52
- #add back in the quotes
53
- final = insert_quotes(quotes, final_result)
54
- else
55
- #add back in the quotes
56
- final = insert_quotes(quotes, result)
57
- end
57
+ classes.each do |cl|
58
+ att += " #{cl[0]}"
59
+ text = text.sub(" ." + cl[0], "")
60
+ end
58
61
 
59
- output += final
62
+ att += '"'
60
63
 
61
- else
62
- output += token
63
- end
64
- end
64
+ #remove the space before the first class
65
+ att = att.sub(/class=" /, ' class="')
65
66
 
66
- return output
67
+ text.sub(TAG_END_REGEX, att + '\1')
67
68
  end
68
69
 
69
70
  def insert_quotes(_quotes, tag)
@@ -1,3 +1,3 @@
1
1
  module Fira
2
- VERSION = "0.5.3"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -42,6 +42,13 @@ describe Fira do
42
42
  result = Fira.render html_comments
43
43
  result.should == res_html_comments
44
44
  end
45
+
46
+ context 'Data tags' do
47
+ it 'simple data tags' do
48
+ result = Fira.render data_attribute_simple
49
+ result.should == res_data_attribute_simple
50
+ end
51
+ end
45
52
  end
46
53
 
47
54
  context 'ERB' do
@@ -55,4 +62,5 @@ describe Fira do
55
62
  result.should == res_erb_in_tag
56
63
  end
57
64
  end
65
+
58
66
  end
@@ -81,7 +81,7 @@ def res_nested_multi_line
81
81
  <p id="id" class="class3">
82
82
  <span id="span8" class="one">some text</span>
83
83
  some text
84
- <input id="user" class="orange" type='text' value='user'/>
84
+ <input id="user" class="orange" type='text' value='user'/>
85
85
  </p>
86
86
  FIRA
87
87
  end
@@ -158,7 +158,7 @@ end
158
158
  def res_erb
159
159
  <<-FIRA
160
160
  <span id="my-id"><% something.id %></span>
161
- <p id="id" class="class3" >
161
+ <p id="id" class="class3">
162
162
  some text
163
163
  </p>
164
164
  FIRA
@@ -176,8 +176,20 @@ end
176
176
  def res_erb_in_tag
177
177
  <<-FIRA
178
178
  <span id="my-id" class="<%= something.id %>" ></span>
179
- <p id="id" class="class3" >
179
+ <p id="id" class="class3">
180
180
  some text
181
181
  </p>
182
182
  FIRA
183
+ end
184
+
185
+ def data_attribute_simple
186
+ <<-FIRA
187
+ <span $convo-id="72" ></span>
188
+ FIRA
189
+ end
190
+
191
+ def res_data_attribute_simple
192
+ <<-FIRA
193
+ <span data-convo-id="72"></span>
194
+ FIRA
183
195
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-27 00:00:00.000000000 Z
12
+ date: 2013-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport