Class: Localite::Template
- Inherits:
-
String
- Object
- String
- Localite::Template
show all
- Defined in:
- lib/localite/template.rb
Defined Under Namespace
Modules: Etest
Classes: Env
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.html(template, opts = {}) ⇒ Object
8
9
10
|
# File 'lib/localite/template.rb', line 8
def self.html(template, opts = {})
new(template).run(:html, opts)
end
|
.run(template, opts = {}) ⇒ Object
4
5
6
|
# File 'lib/localite/template.rb', line 4
def self.run(template, opts = {})
new(template).run(Localite.current_format, opts)
end
|
.text(template, opts = {}) ⇒ Object
12
13
14
|
# File 'lib/localite/template.rb', line 12
def self.text(template, opts = {})
new(template).run(:text, opts)
end
|
Instance Method Details
#run(format, opts = {}) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/localite/template.rb', line 76
def run(format, opts = {})
env = Env.new(opts)
gsub(/\{\*([^\}]+?)\*\}/) do |_|
Localite::Format.send format, env[$1]
end
end
|