djanowski-snippets 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/snippet.rb +6 -1
- metadata +1 -1
data/lib/snippet.rb
CHANGED
@@ -11,9 +11,14 @@ class Snippet < ActiveRecord::Base
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def parse(text, parser = nil)
|
14
|
+
parser = Snippet.default_parser if parser.blank?
|
14
15
|
klass = Snippets::Parsers.const_get(parser.to_s.classify)
|
15
16
|
klass.parse(text)
|
16
17
|
end
|
18
|
+
|
19
|
+
def default_parser
|
20
|
+
'html'
|
21
|
+
end
|
17
22
|
end
|
18
23
|
|
19
24
|
def to_s
|
@@ -23,7 +28,7 @@ class Snippet < ActiveRecord::Base
|
|
23
28
|
private
|
24
29
|
|
25
30
|
def compile_text
|
26
|
-
self.parser =
|
31
|
+
self.parser = Snippet.default_parser if parser.blank?
|
27
32
|
self.compiled_text = Snippet.parse(text, parser)
|
28
33
|
end
|
29
34
|
|