Don't use a constant for api data
This commit is contained in:
parent
0af6c1af84
commit
e5fcd98247
1 changed files with 5 additions and 3 deletions
|
@ -4,7 +4,9 @@ class ApiExampleFilter < Nanoc::Filter
|
||||||
identifier :api_example
|
identifier :api_example
|
||||||
type :text
|
type :text
|
||||||
|
|
||||||
DATA = YAML.load(File.read('content/docs/api_examples.yaml'))
|
def initialize(*args)
|
||||||
|
@data = YAML.load(File.read('content/docs/api_examples.yaml'))
|
||||||
|
end
|
||||||
|
|
||||||
def run(content, params={})
|
def run(content, params={})
|
||||||
content.gsub(/\{(\w+) example\}/) { api_example($1) }.gsub(/\{(\w+) var\}/) { api_var($1) }
|
content.gsub(/\{(\w+) example\}/) { api_example($1) }.gsub(/\{(\w+) var\}/) { api_var($1) }
|
||||||
|
@ -13,10 +15,10 @@ class ApiExampleFilter < Nanoc::Filter
|
||||||
private
|
private
|
||||||
|
|
||||||
def api_example(id)
|
def api_example(id)
|
||||||
DATA[:examples][id.to_sym]
|
@data[:examples][id.to_sym]
|
||||||
end
|
end
|
||||||
|
|
||||||
def api_var(id)
|
def api_var(id)
|
||||||
DATA[:variables][id.to_sym]
|
@data[:variables][id.to_sym]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue