Class: WikiCloth::Extension
- Inherits:
-
Object
- Object
- WikiCloth::Extension
show all
- Defined in:
- lib/wikicloth/extension.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Extension
Returns a new instance of Extension.
4
5
6
|
# File 'lib/wikicloth/extension.rb', line 4
def initialize(options={})
@options = options
end
|
Class Method Details
.element(*args, &block) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/wikicloth/extension.rb', line 18
def element(*args,&block)
options = args.last.is_a?(Hash) ? args.pop : {}
key = args.shift
html_elements[key] = { :klass => self, :block => block, :options => {
:skip_html => false, :run_globals => true }.merge(options) }
end
|
.element_exists?(elem) ⇒ Boolean
36
37
38
|
# File 'lib/wikicloth/extension.rb', line 36
def element_exists?(elem)
html_elements.has_key?(elem)
end
|
.function(name, &block) ⇒ Object
40
41
42
|
# File 'lib/wikicloth/extension.rb', line 40
def function(name,&block)
functions[name] = { :klass => self, :block => block }
end
|
.function_exists?(name) ⇒ Boolean
44
45
46
|
# File 'lib/wikicloth/extension.rb', line 44
def function_exists?(name)
functions.has_key?(name)
end
|
.functions ⇒ Object
14
15
16
|
# File 'lib/wikicloth/extension.rb', line 14
def functions
@@functions ||= {}
end
|
.html_elements ⇒ Object
10
11
12
|
# File 'lib/wikicloth/extension.rb', line 10
def html_elements
@@html_elements ||= {}
end
|
.run_globals?(elem) ⇒ Boolean
31
32
33
34
|
# File 'lib/wikicloth/extension.rb', line 31
def run_globals?(elem)
return false if !element_exists?(elem)
html_elements[elem][:options][:run_globals]
end
|
.skip_html?(elem) ⇒ Boolean
26
27
28
29
|
# File 'lib/wikicloth/extension.rb', line 26
def skip_html?(elem)
return true if !element_exists?(elem)
html_elements[elem][:options][:skip_html]
end
|