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
|
||||
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={})
|
||||
content.gsub(/\{(\w+) example\}/) { api_example($1) }.gsub(/\{(\w+) var\}/) { api_var($1) }
|
||||
|
@ -13,10 +15,10 @@ class ApiExampleFilter < Nanoc::Filter
|
|||
private
|
||||
|
||||
def api_example(id)
|
||||
DATA[:examples][id.to_sym]
|
||||
@data[:examples][id.to_sym]
|
||||
end
|
||||
|
||||
def api_var(id)
|
||||
DATA[:variables][id.to_sym]
|
||||
@data[:variables][id.to_sym]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue