faqml 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/fml/details_filter.rb +10 -2
- data/lib/fml/version.rb +1 -1
- metadata +2 -2
data/lib/fml/details_filter.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
class FAQML::DetailsFilter < Temple::Filter
|
2
|
+
include Temple::Mixins::Options
|
3
|
+
|
4
|
+
set_default_options :id_max_length => 50
|
5
|
+
|
2
6
|
def initialize(options = {})
|
3
|
-
|
7
|
+
super(options)
|
4
8
|
end
|
5
9
|
|
6
10
|
def call(exp)
|
@@ -13,7 +17,7 @@ class FAQML::DetailsFilter < Temple::Filter
|
|
13
17
|
question_sexp.last << answer_sexp unless answer_sexp.nil?
|
14
18
|
|
15
19
|
attrs = [:html, :attrs, [:html, :attr, 'class', [:static, 'qna']]]
|
16
|
-
id = summary.last.first
|
20
|
+
id = convert_to_id(summary.last.first)
|
17
21
|
attrs << [:html, :attr, 'id', [:static, id]] unless id == ''
|
18
22
|
[:html, :tag, 'section', attrs,
|
19
23
|
question_sexp
|
@@ -22,6 +26,10 @@ class FAQML::DetailsFilter < Temple::Filter
|
|
22
26
|
|
23
27
|
private
|
24
28
|
|
29
|
+
def convert_to_id(str)
|
30
|
+
str.to_s.downcase.gsub(/(\<.+?\>)/, '').gsub(/[\W]/, ' ')[0...options[:id_max_length]].strip.gsub(/\s+/, '-')
|
31
|
+
end
|
32
|
+
|
25
33
|
def build_fml_details(class_name, open, summary, details)
|
26
34
|
attrs = [:html, :attrs, [:html, :attr, 'class', [:static, class_name]] ]
|
27
35
|
# open if marked as open, or has no summary
|
data/lib/fml/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faqml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
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:
|
12
|
+
date: 2013-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redcarpet
|